Skip to content

Fix: Improve inventory validation and handle empty cart/inventory #814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

seer-by-sentry[bot]
Copy link
Contributor

@seer-by-sentry seer-by-sentry bot commented May 7, 2025

👋 Hi there! This PR was automatically generated by Autofix 🤖

This fix was triggered by Neil Manvar.

Fixes FLASK-1N. The issue was that: Requested quantity (6) for product 3 exceeded available inventory (1), triggering the 'Not enough inventory' exception during checkout.

  • Ensure product IDs are strings when formatting for the SQL query.
  • Refactor inventory validation to use a map for efficient lookup.
  • Improve error messages to include product IDs and quantities.
  • Add checks for empty cart or inventory to prevent errors.
  • Increment checkout.failed metric when inventory validation fails.

If you have any questions or feedback for the Sentry team about this fix, please email [email protected] with the Run ID: 38736.

Copy link

vercel bot commented May 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
empower ⬜️ Ignored (Inspect) Visit Preview May 7, 2025 4:46pm

Copy link

sentry-io bot commented May 7, 2025

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: flask/src/db.py

Function Unhandled Issue
get_inventory DatabaseConnectionError: get_inventory checkout
Event Count: 38
📄 File: flask/src/main.py (Click to Expand)
Function Unhandled Issue
checkout Exception: Not enough inventory for product checkout
Event Count: 4.9k
checkout DatabaseConnectionError: get_inventory checkout
Event Count: 38
checkout UnboundLocalError: cannot access local variable 'e' where it is not associated with a value ...
Event Count: 1
---

Did you find this useful? React with a 👍 or 👎

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.

0 participants