Guard deconstructRegistration against null Registration#451
Merged
Conversation
Intercom.client().fetchLoggedInUserAttributes() returns null when no user is logged in (e.g. after the OS kills and restarts the process, clearing the native session). Both the oldarch and newarch IntercomModule pass that return value straight into IntercomHelpers.deconstructRegistration(), which immediately calls registration.getEmail() and throws a fatal NullPointerException on the JS bridge thread. Return an empty map when registration is null, matching the iOS bridge, which resolves an empty dictionary for the same "no logged-in user" case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jasonpraful
approved these changes
Jun 16, 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.
What
Adds a null guard at the top of
IntercomHelpers.deconstructRegistration(...)so it returns an emptyWritableMapwhen theRegistrationisnull, instead of crashing.Why
Intercom.client().fetchLoggedInUserAttributes()returnsnullby design when no user is logged in — the native Android SDK documents this (fetchLoggedInUserAttributes(): Registration?). This happens, for example, after the OS kills and restarts the app process (clearing the in-memory native session) and the app callsfetchLoggedInUserAttributes()before re-registration completes.Both
oldarchandnewarchIntercomModule.fetchLoggedInUserAttributes()pass that return value straight intodeconstructRegistration(...):deconstructRegistrationthen dereferencesregistration.getEmail()on its first line, throwing a fatalNullPointerExceptionon the JS bridge thread (UncaughtExceptionHandler→ process death).This is a platform parity gap: the iOS bridge (
IntercomAttributesBuilder.dictionaryForUserAttributes:) reads attributes on a possibly-nilICMUserAttributesand, thanks to Obj-C nil-messaging, resolves an empty dictionary ({}) for the same "no logged-in user" case. The fix brings Android to the same behavior, which also satisfies the existing non-nullable TS contractfetchLoggedInUserAttributes: () => Promise<UserAttributes>.The native Android SDK is correct and unchanged — the nullable return is by design; only the RN bridge needed the guard. Pre-existing bug, not a regression (present in every release from 9.8.0 onward).
Crash (production)
Tests
The
android/library module has no JUnit/Robolectric test harness, anddeconstructRegistrationdepends on RN'sArguments.createMap()bridge runtime. Standing up a test harness is out of scope for this one-line fix; the change is a straightforward null guard with a behavior matching the already-shipped iOS path.Related
~ Automated via Claude