Fix checkout payload so /checkout stops returning 500 - #265
Open
sentry[bot] wants to merge 1 commit into
Open
Conversation
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/)
Codecov Report❌ Patch coverage is
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. 🚀 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.
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 withname, but the/productsresponse and the backend/checkouthandler both usetitle. When an item was out of stock the backend looked upitem['title'], hit aKeyError, and returned HTTP 500. The payload was also missingcart.total, which the backend reads on the all-in-stock path, so that branch failed the same way. Since the app callsprocessDeliveryItem()on any non-2xx checkout response, and that method unconditionally throwsBackendAPIException("Failed to init delivery workflow"), every failed checkout surfaced as this error.Solution
Send
titlefor each cart item (still sourced from the store item name) and include the computedcart.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
/checkoutinventory logic. The old payload reproducedKeyError: 'title'→ "Error validating enough inventory for product"; the new payload returns success, partial, and failed statuses correctly for full, partial, and empty inventory.