fix: tolerate empty deepLinkData object in InstallResponse - #4
Open
onamfc wants to merge 1 commit into
Open
Conversation
The install endpoint returns `deepLinkData: {}` rather than `null` for
organic (unattributed) installs. `DeepLinkData.shortCode` is required, so
Moshi threw `JsonDataException` and the whole install response failed to
decode, surfacing as a DecodingError out of `initialize()`.
Register a lenient `DeepLinkData` adapter on the network Moshi instance: an
empty object — or any payload without a usable short code — decodes to null
instead of throwing, matching the `null` and absent cases. The failure is
logged when debug logging is on, since a deep link we cannot decode is never
worth aborting attribution over. Required top-level fields stay strict, and
locally stored deep link data (written by the SDK) keeps its strict adapter.
Ports the iOS SDK fix (LinkForty/mobile-sdk-ios#4) to Android.
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.
Ports the iOS SDK fix (mobile-sdk-ios#4) to Android. The bug was reported against iOS, but Android has the same defect.
Problem
The install endpoint returns
deepLinkData: {}rather thannullfor organic (unattributed) installs:{ "installId": "<some_id>", "attributed": false, "confidenceScore": 0, "matchedFactors": [], "deepLinkData": {} }DeepLinkData.shortCodehas no default, so the generated Moshi adapter threwJsonDataException: Required value 'shortCode' missing. That happened while decoding the enclosingInstallResponse, so the whole response failed andinitialize()surfaced aLinkFortyError.DecodingErrorfor every organic install — not just the deep link part of it.Fix
A
LenientDeepLinkDataAdapterregistered on the networkMoshiinstance. It reads the value, delegates to the generated adapter, and returnsnullif the payload isn't a usable deep link — so{}, a non-object, and a short-code-less object all mean "no deep link", the same asnulland absent. The failure is logged when debug logging is on rather than propagated, since a deep link the SDK can't parse is never worth aborting attribution over.Deliberately unchanged:
DeepLinkData.shortCodestays non-null. Making it nullable (or defaulting it to"") would be a breaking change for callers that route on it, and a defaulted short code would produce a fake non-null deep link for organic installs — worse than the bug.installId,attributed,confidenceScore, andmatchedFactorsare always returned, andinstallIdis required for the SDK to work at all.NetworkManager's Moshi;StorageManagerandAttributionContextdecode data the SDK itself wrote.The adapter lives in
com.linkforty.sdk.models, whichconsumer-rules.proalready keeps in full, so R8 won't strip the reflectively-invoked@FromJson/@ToJsonmethods.Fixing this SDK-side rather than only backend-side is what actually unblocks integrators: self-hosted deployments and already-deployed backends will keep sending
{}, and the SDK has to survive that.Tests
New
InstallResponseTestcovers{},null, absent, and short-code-lessdeepLinkData, the attributed path, a missing-installIdfailure, and encode/decode round trips. ANetworkManagerTestcase decodes an organic response end-to-end, so the adapter registration itself is guarded — I verified that test fails without it. Full suite: 146 tests passing,lintDebugclean.