fix(android): return real success value from initTerra and initConnection [UNVERIFIED ON LIVE]#24
Open
Ant1Miller wants to merge 1 commit into
Open
fix(android): return real success value from initTerra and initConnection [UNVERIFIED ON LIVE]#24Ant1Miller wants to merge 1 commit into
Ant1Miller wants to merge 1 commit into
Conversation
…tion The Android bridge hardcoded success: true in the initTerra and initConnection result maps, discarding the native SDK's completion boolean. A failed Samsung Health permission or connection flow reached Dart as a success with only the error field set, so apps branching on success saw a silent no-op instead of a failure. initConnection now forwards the native boolean, matching the sibling getters in the same file. initTerra keys off error == null, since Terra.Companion.instance's callback exposes no success flag and hands back a non-null TerraManager even on failure. Bumps to 0.9.0-samsung.4 so affected customers can consume the fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Ant1Miller
force-pushed
the
fix/samsung-initconnection-success
branch
from
July 14, 2026 12:31
4b79c65 to
560c019
Compare
Author
|
/sfs |
Author
|
/sfs |
Contributor
|
MEP — no new commits since my last review on this PR — nothing to add. push a commit and re-run |
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.

Summary
The Android Flutter bridge hardcoded
map.put("success", true)in bothinitTerraandinitConnection, discarding the success boolean the native SDK returns. A failed Samsung Health permission/connect flow therefore reached Dart assuccess: truewith only theerrorfield populated, so a customer app branching onsuccesssaw a silent no-op rather than a failure.Found while investigating ZD-6058 (Samsung Health integration dead on some devices: no permission dialog, no webhook, nothing surfaced to the app).
Changes
android/src/main/java/co/tryterra/terra_flutter_bridge/TerraFlutterPlugin.javainitConnectionforwards the native boolean:map.put("success", success). This matches the four sibling getters in the same file, which already do this.initTerrakeys offerror == null. A passthrough is not available here:Terra.Companion.instance's callback is(TerraManager, TerraError?)with no success flag, andTerraInterface.kt:27-31force-unwraps a non-nullTerraManagereven on failure, soterraManager != nullwould be always-true and would silently reproduce the bug. Every SDK failure branch carries a non-null error and the sole success path iscompletion(true, null), soerror == nullis equivalent to the discarded flag.Rebased onto
samsungafter 0.9.0-samsung.4 shipped; this releases as 0.9.0-samsung.5. Orthogonal to the 0.0.12 crash fix in 0.9.0-samsung.4: that one stops the init crash when Samsung Health is absent, this one stops a failed init from being reported as a success. A caller needs both to reliably detect and handle a bad Samsung connect.Behaviour change
Apps that assumed
successwas always true will now start seeingsuccess: falseon genuine failures. That is the point of the fix, but it is visible, hence the CHANGELOG note.erroris unchanged. iOS has always behaved this way (SwiftTerraFlutterPlugin.swift:176/180/201), so this brings Android to parity with the contract iOS already ships, and any app that handles iOS correctly already handles this.Relationship to #19
#19 is the same
initConnectionone-liner but targetsmain, and has been open since 12 June. Samsung-tagged releases are published fromsamsung, so #19 does not reach the affected customer. This PR targetssamsung.mainstill needs both fixes. #19 covers onlyinitConnectionthere; theinitTerrabug exists onmaintoo and is not covered by any open PR.Verification
UNVERIFIED ON LIVE. The bug is confirmed by code read, and the fix is a two-line correction to a value that was provably discarded, reviewed against the native SDK's callback contracts. It has not been run against the customer's failing device, and this repo has no harness that can reach the Java bridge (
test/terra_flutter_test.dartis an empty stub that mocks the MethodChannel; there is noandroid/src/test). Adding one would mean new test dependencies, deliberately left out of scope.The real proof is the customer's next release build on a failing device surfacing an actual Samsung error string instead of nothing.
Follow-up, not in this PR
TerraInterface.kt:29receives the realsuccess: BooleanfromcreateInstanceand throws it away, forwarding only the error. This bridge'serror == nullis correct only because the SDK never callscompletion(false, null)today. Widening that callback to pass the boolean through would make the invariant enforced rather than assumed.🤖 Generated with Claude Code