fix: resolve null assertion crashes and correct API mapping in Networ…#1041
fix: resolve null assertion crashes and correct API mapping in Networ…#1041vibhutomer wants to merge 1 commit into
Conversation
…kService Signed-off-by: vibhutomer <vibhutomer25@gmail.com>
WalkthroughTwo targeted safety improvements to network service error handling: ChangesNetwork Service Safety Improvements
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/platform_android/network_service_impl.dart (1)
84-90:⚠️ Potential issue | 🔴 Critical | ⚡ Quick win
saveScreenHeaderToGlobalParamstill calls the wrong API and can overwrite version dataLine 87 still invokes
saveVersionToGlobalParam, so this method does not satisfy the fix objective and can corrupt global params. Also, Line 89’sPlatformExceptionmessage still references the version API, which will mislead debugging.Proposed fix
`@override` Future<String> saveScreenHeaderToGlobalParam(String id, String value) async { String response = ""; try { - response = await CommonDetailsApi().saveVersionToGlobalParam(id, value); + response = + await CommonDetailsApi().saveScreenHeaderToGlobalParam(id, value); } on PlatformException { - debugPrint('SaveVersionToGlobalParam Api Call Failed'); + debugPrint('SaveScreenHeaderToGlobalParam Api Call Failed'); } catch (e) { debugPrint('Save screen header failed: $e'); } return response; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/platform_android/network_service_impl.dart` around lines 84 - 90, The saveScreenHeaderToGlobalParam method is still calling CommonDetailsApi().saveVersionToGlobalParam and logs a PlatformException message referencing the version API; change the API call to the correct endpoint (e.g., CommonDetailsApi().saveScreenHeaderToGlobalParam or the intended method name) and update the PlatformException debugPrint string to refer to the screen header/global param API so it no longer overwrites version data or misleads debugging; ensure the method name saveScreenHeaderToGlobalParam and the CommonDetailsApi call are consistent and return the response as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@lib/platform_android/network_service_impl.dart`:
- Around line 84-90: The saveScreenHeaderToGlobalParam method is still calling
CommonDetailsApi().saveVersionToGlobalParam and logs a PlatformException message
referencing the version API; change the API call to the correct endpoint (e.g.,
CommonDetailsApi().saveScreenHeaderToGlobalParam or the intended method name)
and update the PlatformException debugPrint string to refer to the screen
header/global param API so it no longer overwrites version data or misleads
debugging; ensure the method name saveScreenHeaderToGlobalParam and the
CommonDetailsApi call are consistent and return the response as before.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8f1f7c40-d7f7-4909-a523-92eb359b6898
📒 Files selected for processing (1)
lib/platform_android/network_service_impl.dart
Description
This PR resolves two high-priority bugs in
NetworkServiceImplthat lead to data corruption and potential runtime crashes.Changes Made
saveScreenHeaderToGlobalParamwhere it was incorrectly invokingsaveVersionToGlobalParam. It now routes to the proper screen header API to prevent overwriting version data.getVersionNoApp(), removed the strict bang operator (!) when parsing thebuild['version']map. Replaced it with a null-aware operator (?? 'Unknown') to ensure the app does not crash with aTypeErrorif the backend omits the version key.Related Issue
Closes #1040
Type of Change
Checklist
Summary by CodeRabbit