Skip to content

Fix: Only call processDeliveryItem on successful checkout response#220

Open
sentry[bot] wants to merge 1 commit into
mainfrom
claude/fix-checkout-delivery-ordering-d71d5d
Open

Fix: Only call processDeliveryItem on successful checkout response#220
sentry[bot] wants to merge 1 commit into
mainfrom
claude/fix-checkout-delivery-ordering-d71d5d

Conversation

@sentry
Copy link
Copy Markdown

@sentry sentry Bot commented May 21, 2026

Summary

Fixes a bug where processDeliveryItem() was called in the failure paths of the checkout HTTP callback, causing BackendAPIException: Failed to init delivery workflow to be thrown after an already-failed checkout.

Root Cause

The checkout flow in MainFragment.java had its success/failure logic inverted:

  • Before: processDeliveryItem() was called when !response.isSuccessful() (failure) and in onFailure() (network error), but never on success.
  • After: processDeliveryItem() is called only when response.isSuccessful() (success), and removed from both failure paths.

When the Flask backend returns HTTP 500 (e.g., due to an UnboundLocalError on the quantities variable), the Android app was proceeding to call processDeliveryItem(), which always throws BackendAPIException("Failed to init delivery workflow") — compounding the error.

Changes

MainFragment.javacheckout() method:

  • Moved processDeliveryItem(checkoutTransaction) from the !success branch to the success branch in onResponse
  • Removed processDeliveryItem() call from onFailure
  • Transaction now finishes with SpanStatus.OK on success, SpanStatus.INTERNAL_ERROR on failure

Fixes ANDROID-FZ

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
@sentry sentry Bot requested a review from ndmanvar as a code owner May 21, 2026 06:06
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (814e302) to head (e340e18).

Files with missing lines Patch % Lines
.../example/vu/android/empowerplant/MainFragment.java 0.00% 4 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant