Handle legacy persisted domain mappings safely#703
Conversation
PR SummaryMedium Risk Overview
Adds regression tests covering legacy mappings without Reviewed by Cursor Bugbot for commit 46d8070. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
jamesnrokt
left a comment
There was a problem hiding this comment.
Verified locally against the Higgs Shop sample app on Pixel_9 emulator.
Pass A (main): legacy JSON → JSONException + NPE matching the report, domainMappings.size=0 (all mappings silently dropped).
Pass B (this branch): same input → domainMappings.size=2, configDomain populated with overridesSubdirectory=false default, no exceptions.
Reproduces the original failure and confirms the fix. LGTM.
Thanks for the clean, minimal fix and the regression tests — great first contribution, looking forward to more!



Background
DomainMappingparsing began expectingoverridesSubdirectoryto always be present.UploadSettings/NetworkOptionsJSON containing legacydomainMappingsentries that do not includeoverridesSubdirectory.No value for overridesSubdirectoryAttempt to invoke virtual method 'com.mparticle.networking.DomainMapping com.mparticle.networking.DomainMapping$Builder.build()' on a null object referenceoverridesSubdirectoryto always be present, which caused legacy entries to fail parsing.NetworkOptionsflow, that parse failure could produce a nullDomainMapping.Builder, and the subsequent.build()call could trigger a null object reference crash.What Has Changed
DomainMappingJSON parsing to use a backward-compatible default offalsewhenoverridesSubdirectoryis missing.NetworkOptionsparsing so invalid persisted domain mapping entries are skipped instead of crashing the entire parse flow.DomainMappingJSON withoutoverridesSubdirectoryNetworkOptionsJSON with one valid persisted mapping and one invalid mappingScreenshots/Video
Checklist
Additional Notes
./gradlew :android-core:testDebugUnitTest --tests com.mparticle.networking.NetworkOptionsTest