Repository navigation
fix: [SDK-5332] validate public API inputs to prevent native crashes - #1186
Merged
Merged
Conversation
fadi-george
reviewed
Sep 22, 2026
Blank login, app id, language, alias, email, sms, tag key, trigger key, and custom event names were forwarded to native. One helper now drops those calls. Co-authored-by: Cursor <cursoragent@cursor.com>
Empty language is the only reset path, so the blank-string guard was a breaking change. Co-authored-by: Cursor <cursoragent@cursor.com>
The checks read as predicates: isMissing, isMissingAny, and hasMissingEntries.
fadi-george
force-pushed
the
ar/sdk-5332
branch
from
October 3, 2026 05:48
887d479 to
22e468c
Compare
fadi-george
approved these changes
Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Validate public API inputs in Dart so invalid values return before reaching the native SDKs.
Details
Motivation
Fixes SDK-5332. Part of SDK-5327, matching react-native-onesignal#1997.
Empty identity strings were forwarded to the native channel. Some public methods also take
dynamicordoublevalues that Dart's types don't constrain, and the native bridges pass them through as is.Dart's sound null safety already stops null or wrong-typed
String,bool,int, and enum arguments, so the React Native boolean, integer, and log level guards aren't needed here.Scope
isMissinginlib/src/utils.dartrejects null and empty strings for:initialize(appId)login(externalId)addAlias/addAliases(label and id)removeAlias/removeAliasesaddEmail/removeEmailaddSms/removeSmsaddTagWithKey/addTags(key only). An empty tag value is allowed. A null tag value is rejected.removeTag/removeTagsaddTrigger/addTriggers(key only). An empty trigger value is allowed.removeTrigger/removeTriggerstrackEvent(name)addOutcome/addUniqueOutcome/addOutcomeWithValue(name)removeGroupedNotifications(notificationGroup)enterLiveActivity(activityId, token),exitLiveActivity(activityId),setPushToStartToken(activityType, token),removePushToStartToken(activityType),startDefault(activityId)Additional checks:
startDefaultrequiresattributesandcontentto be maps. Both aredynamic, and the iOS bridge passes them straight through asNSDictionary.addOutcomeWithValuerejectsNaNand infinite values. Native handling differs: Android sendsNaNas an outcome with no value, and+Infinitythrows a caughtJSONExceptionthat drops the outcome.Rejected calls log a
[OneSignal]message through a sharedlogErrorhelper. Whitespace is still allowed. Public method signatures are unchanged.setLanguage("")is not rejected. It is the reset to the device language, and there is no other reset path.Testing
Unit testing
flutter testpassed (272 tests). New and updated tests cover the rejection paths for login, tags, email, outcomes (empty name and non-finite value),removeGroupedNotifications, and every Live Activities method, including non-mapstartDefaultattributes and content.flutter analyze lib testreported no issues.Manual testing
Not run. The guards return before the method channel call, and the unit tests assert the mock channel is not invoked.
Affected code checklist
Checklist
Overview
Testing
Final pass