fix: tolerate empty deepLinkData object in InstallResponse - #7
Merged
Conversation
The install endpoint returns `deepLinkData: {}` rather than `null` for
organic (unattributed) installs. `DeepLinkData.shortCode` is required, so
`InstallResponse.fromJson` threw a TypeError and `initialize()` failed for
every organic install.
Parse `deepLinkData` leniently: an empty object — or any payload without a
usable short code — is now treated as "no deep link" (null), matching the
`null` and absent cases. The failure is logged when debug logging is on
instead of failing the whole response, since a deep link we cannot parse is
never worth aborting attribution over. Required top-level fields stay strict.
Ports the iOS SDK fix (LinkForty/mobile-sdk-ios#4) to Flutter.
# Conflicts: # CHANGELOG.md
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 Flutter. The bug was reported against iOS, but Flutter 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.shortCodeisrequired, so the generatedDeepLinkData.fromJsonthrew aTypeErroronjson['shortCode'] as String. That happened insideInstallResponse.fromJson, so the whole response failed to parse andinitialize()threw for every organic install — not just the deep link part of it.Fix
deepLinkDatanow parses through@JsonKey(fromJson: _deepLinkDataFromJson): anything that isn't a map, or thatDeepLinkData.fromJsonrejects, becomesnull— so{}and a short-code-less object mean "no deep link", the same asnulland absent. The failure is logged when debug logging is on rather than rethrown, since a deep link the SDK can't parse is never worth aborting attribution over.Deliberately unchanged:
DeepLinkData.shortCodestaysrequired. A deep link without a short code isn't routable, and loosening it would be a breaking change for anything reading it.installId,attributed,confidenceScore, andmatchedFactorsare always returned, andinstallIdis required for the SDK to work at all.toJsonis untouched — the generated serializer still emitsdeepLinkData?.toJson().install_response.g.dartis regenerated withbuild_runner; the only change is the one call site.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
install_response_test.dartgains coverage for{},null, and short-code-lessdeepLinkData, the attributed path, and a missing-required-field failure. Full suite: 106 tests passing,flutter analyzeclean.