Fix: Only call processDeliveryItem on successful checkout response#220
Open
sentry[bot] wants to merge 1 commit into
Open
Fix: Only call processDeliveryItem on successful checkout response#220sentry[bot] wants to merge 1 commit into
sentry[bot] wants to merge 1 commit into
Conversation
processDeliveryItem() was being called in the failure paths (when
checkout HTTP response was not successful or on network failure),
causing BackendAPIException to be thrown after an already-failed
checkout. This happened because the Flask backend returns HTTP 500
due to an UnboundLocalError on the quantities variable, and the
Android app would then proceed to call processDeliveryItem() which
always throws BackendAPIException('Failed to init delivery workflow').
Move processDeliveryItem() to only be called when the checkout
response is successful, and remove it from both failure paths
(onResponse with !success and onFailure).
Fixes ANDROID-FZ
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #220 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 16 16
Lines 864 863 -1
Branches 65 65
=====================================
+ Misses 864 863 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Fixes a bug where
processDeliveryItem()was called in the failure paths of the checkout HTTP callback, causingBackendAPIException: Failed to init delivery workflowto be thrown after an already-failed checkout.Root Cause
The checkout flow in
MainFragment.javahad its success/failure logic inverted:processDeliveryItem()was called when!response.isSuccessful()(failure) and inonFailure()(network error), but never on success.processDeliveryItem()is called only whenresponse.isSuccessful()(success), and removed from both failure paths.When the Flask backend returns HTTP 500 (e.g., due to an
UnboundLocalErroron thequantitiesvariable), the Android app was proceeding to callprocessDeliveryItem(), which always throwsBackendAPIException("Failed to init delivery workflow")— compounding the error.Changes
MainFragment.java—checkout()method:processDeliveryItem(checkoutTransaction)from the!successbranch to thesuccessbranch inonResponseprocessDeliveryItem()call fromonFailureSpanStatus.OKon success,SpanStatus.INTERNAL_ERRORon failureFixes ANDROID-FZ