Skip to content
This repository was archived by the owner on Jul 11, 2025. It is now read-only.

Refactor checkout process to handle inventory and errors #32

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seer-by-sentry[bot]
Copy link

Fixes REACT-5FV. The issue was that: Backend inventory check failed for product ID 4 (Botana Voice) as requested quantity (3) exceeded available stock (2), causing an unhandled exception and 500 error.

  • Implemented more robust inventory management during checkout.
  • Added InsufficientInventoryError exception for handling out-of-stock situations.
  • Modified process_order to check for sufficient inventory and raise exceptions.
  • Updated the /checkout route to handle InsufficientInventoryError and ValueError exceptions, returning appropriate HTTP status codes and JSON responses.
  • Added error handling for invalid product IDs and quantities.
  • Improved error reporting to the client with specific error messages and product IDs when applicable.
  • Updated inventory levels for items.

This fix was generated by Seer in Sentry, triggered automatically. 👁️ Run ID: 61612

Not quite right? Click here to continue debugging with Seer.

Comment on lines +91 to +95
return jsonify({
"error": "InsufficientInventory",
"message": str(e),
"product_id": e.product_id
}), 409 # Use 409 Conflict

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
"product_id": e.product_id
}), 409 # Use 409 Conflict
except ValueError as e:
return jsonify({"error": "BadRequest", "message": str(e)}), 400 # Use 400 Bad Request

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants