Null-guard Configuration.locale in MessageBuilder#299
Open
Conversation
Skip the _lg property when Configuration.locale is null. On affected Samsung SM-A566B devices (Android 15/16), the locale field can be transiently null during a locale transition, causing an NPE on the analytics flush background thread. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
Author
|
Claude local review:
|
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.
See: https://a8c.sentry.io/issues/7311890982/?project=5731682&referrer=project-issue-stream&seerDrawer=true
Summary
MessageBuilder.java:68whenConfiguration.localeis transiently null during a locale transition on Samsung SM-A566B devices (Android 15/16, firmwareBP2A.250605.031.A3.*). The NPE fires on the Tracks analytics flush background thread and crashes the host app._lgproperty is skipped entirely rather than emitted as an empty string, so the server sees a missing field instead of mixing a fallback value into the realLocale.ROOTbucket in analytics.Context
Reported as JETPACK-ANDROID-1G35. Reproduces when the device/app locale is switched to
hr,sr, orbson an affected Samsung A56 build and an analytics event fires mid-transition.Configuration.localebriefly returns null, violating the documented JVM/Android contract, and.toString()throws.Only
MessageBuilder.createRequestCommonPropsJSONObject()is patched here — that's the exact call site named in the crash report.DeviceInformation.java:101-102has a similarLocale.getDefault().toString()pattern but runs once duringTracksClientinit; it could be hardened in a follow-up if we want full library-side coverage.Note: the original bug report describes the crash as
Locale.getDefault().toString(), but line 68 actually readsConfiguration.locale— different field, same NPE shape. The fix targets the real code path.Test plan
./gradlew :AutomatticTracks:assembleDebug./gradlew :AutomatticTracks:lintDebug🤖 Generated with Claude Code