Skip to content

Fix checkout error handling: guard processDeliveryItem on success only#228

Open
sentry[bot] wants to merge 1 commit into
mainfrom
claude/fix-checkout-inventory-validation-d174e3d7
Open

Fix checkout error handling: guard processDeliveryItem on success only#228
sentry[bot] wants to merge 1 commit into
mainfrom
claude/fix-checkout-inventory-validation-d174e3d7

Conversation

@sentry

@sentry sentry Bot commented Jun 24, 2026

Copy link
Copy Markdown

Summary

Fixes ANDROID-HQ

The Android app was unconditionally calling processDeliveryItem after checkout regardless of the HTTP response status. Additionally, processDeliveryItem contained a hardcoded throw new BackendAPIException, which caused every checkout attempt to capture an error event in Sentry (15,901 occurrences since March 2026).

Root Cause

  1. In onResponse, when the checkout HTTP response was not successful (!success), the app still called processDeliveryItem.
  2. In onFailure, processDeliveryItem was also called unconditionally.
  3. processDeliveryItem itself contained throw new BackendAPIException("Failed to init delivery workflow") — a hardcoded throw that always triggered, causing the ANDROID-HQ Sentry issue.

Changes

  • Guard processDeliveryItem on successful checkout only: In onResponse, only call processDeliveryItem when response.isSuccessful() is true. On failure, dismiss the dialog and finish the transaction with INTERNAL_ERROR status.
  • Remove processDeliveryItem from onFailure: Network failures should not trigger delivery processing.
  • Remove hardcoded throw from processDeliveryItem: Replace the unconditional throw new BackendAPIException with proper span completion logic (set status to OK and finish the span).

Related

See also the companion Flask backend fix in sentry-demos/empower for the server-side inventory validation errors that return HTTP 500.

Fixes ANDROID-HQ

- Only call processDeliveryItem when checkout response is successful
- Remove processDeliveryItem call from onFailure callback
- Remove hardcoded throw from processDeliveryItem; replace with
  proper span completion logic
- On checkout failure, dismiss dialog and finish transaction with
  INTERNAL_ERROR status without triggering processDeliveryItem
@sentry sentry Bot requested a review from sdzhong as a code owner June 24, 2026 02:30
@sentry

sentry Bot commented Jun 24, 2026

Copy link
Copy Markdown
Author

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Android com.example.vu.android 24.12.26 (241226) release
Android com.example.vu.android 24.12.26 (241226) debug
Android com.example.vu.android 24.12.26 (241226) release

⚙️ android Build Distribution Settings

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (fbd7a20) to head (081a77f).

Files with missing lines Patch % Lines
.../example/vu/android/empowerplant/MainFragment.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #228   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines        875     870    -5     
  Branches      65      64    -1     
=====================================
+ Misses       875     870    -5     

☔ View full report in Codecov by Harness.
📢 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