Skip to content

Fix checkout payload so /checkout stops returning 500 - #265

Open
sentry[bot] wants to merge 1 commit into
mainfrom
claude/fix-checkout-payload-title-011CTS8bcRDbHFYcW4kEbG7L
Open

Fix checkout payload so /checkout stops returning 500#265
sentry[bot] wants to merge 1 commit into
mainfrom
claude/fix-checkout-payload-title-011CTS8bcRDbHFYcW4kEbG7L

Conversation

@sentry

@sentry sentry Bot commented Aug 25, 2026

Copy link
Copy Markdown

This pull request was triggered by a Seer handoff from Sentry.

Fixes ANDROID-KV

Root cause

The checkout request built in MainFragment.buildJSONPostData() labelled each cart item with name, but the /products response and the backend /checkout handler both use title. When an item was out of stock the backend looked up item['title'], hit a KeyError, and returned HTTP 500. The payload was also missing cart.total, which the backend reads on the all-in-stock path, so that branch failed the same way. Since the app calls processDeliveryItem() on any non-2xx checkout response, and that method unconditionally throws BackendAPIException("Failed to init delivery workflow"), every failed checkout surfaced as this error.

Solution

Send title for each cart item (still sourced from the store item name) and include the computed cart.total, matching the payload the backend and the web client expect. With this shape the checkout succeeds — or returns a normal partial/failed status for genuinely out-of-stock items — instead of 500ing and triggering the delivery workflow error.

Verification

The Android toolchain isn't available in this environment, so the payload builder was replicated in a standalone harness and its output run through a simulation of the backend /checkout inventory logic. The old payload reproduced KeyError: 'title' → "Error validating enough inventory for product"; the new payload returns success, partial, and failed statuses correctly for full, partial, and empty inventory.

The Android checkout payload labelled each cart item with "name", while
the /products endpoint and the backend /checkout handler both use
"title". When an item was out of stock the backend looked up
item['title'] and raised a KeyError, returning HTTP 500. The success
path also reads cart['total'], which the app never sent. Any non-2xx
checkout response makes the app call processDeliveryItem(), which fires
the "Failed to init delivery workflow" error.

Use "title" for cart items and include the cart total so /checkout can
process the order.

Fixes [ANDROID-KV](https://demo.sentry.io/issues/7653030577/)
@sentry
sentry Bot requested a review from sdzhong as a code owner August 25, 2026 12:19
@sentry

sentry Bot commented Aug 25, 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 Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (21c77a4) to head (92f450b).

Files with missing lines Patch % Lines
.../example/vu/android/empowerplant/MainFragment.java 0.00% 4 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main    #265   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files         16      16           
  Lines        883     886    +3     
  Branches      67      67           
=====================================
- Misses       883     886    +3     

☔ 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