Repository navigation
fix(functions): guard null and non-string error details in platformExceptionToFirebaseFunctionsException - #18827
Conversation
…ceptionToFirebaseFunctionsException
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
Description
Fixes a null-check crash (
message!) and uncheckeddetailscasts inplatformExceptionToFirebaseFunctionsException(packages/cloud_functions/cloud_functions_platform_interface/lib/src/method_channel/utils/exception.dart, lines 34–59).Why this is needed
PlatformException,platformExceptionToFirebaseFunctionsExceptionpreviously assumed:platformException.detailsis eithernullor aMap(Map<String, dynamic>.from(platformException.details)at line 35).details['code']anddetails['message']areString?when non-null.details['message']orplatformException.messageis non-null, passingmessage: message!(line 55) toFirebaseFunctionsException(whosemessageparameter isString?).localizedDescription/getMessage()isnullanddetails['message']isnull),message!throws aTypeError(Null check operator used on a null value) instead of returning aFirebaseFunctionsException. Similarly, ifdetailsis not aMapor contains non-Stringcode/messagevalues, the conversion throws aTypeErrorbefore the caller'son FirebaseFunctionsException catchhandler can run.Why this does not break existing SDK behavior
platformException.detailsis aMapwithStringcodeandmessage(or whenplatformException.messageis a non-nullString), the returnedFirebaseFunctionsExceptionhas the exact samecode,message,details(additionalData), andstackTraceas before.TypeErrorinside the exception converter (detailsnot aMap, non-Stringdetails['code']/details['message'], or bothdetails['message']andplatformException.messagebeingnull) now safely fall back (message: message ?? code, matching_flutterfire_internals'splatformExceptionToFirebaseException).Verification
387c707b2with only the new tests):flutter test --no-pub test/method_channel/method_channel_https_callable_test.dartfails with:d81d4b71a):dart format --output=none --set-exit-if-changed .(0 changes)dart analyze --fatal-infos .(0 issues)flutter test --no-pubincloud_functions_platform_interface(28 passed, 0 failed)Related Issues
N/A
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]).This will ensure a smooth and quick review process. Updating the
pubspec.yamland changelogs is not required.///).melos run analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?