-
Notifications
You must be signed in to change notification settings - Fork 13
Improve checkout process with error handling and inventory management #23
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
base: master
Are you sure you want to change the base?
Conversation
return jsonify({ | ||
"error": "InsufficientInventory", | ||
"message": str(e), | ||
"product_id": e.product_id | ||
}), 409 |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
To fix the issue, the exception messages should not be directly included in the response sent to the client. Instead, a generic error message should be returned, and the detailed exception message should be logged for internal use. This ensures that sensitive information is not exposed to external users while still allowing developers to debug issues using the logs.
The changes required are:
- Replace the
str(e)
usage in the JSON response with a generic error message. - Log the exception message internally using
sentry_sdk.capture_exception(e)
or another logging mechanism.
-
Copy modified line R91 -
Copy modified line R94 -
Copy modified lines R98-R99
@@ -90,5 +90,6 @@ | ||
except InsufficientInventoryError as e: | ||
sentry_sdk.capture_exception(e) | ||
return jsonify({ | ||
"error": "InsufficientInventory", | ||
"message": str(e), | ||
"message": "Not enough inventory for the requested product.", | ||
"product_id": e.product_id | ||
@@ -96,3 +97,4 @@ | ||
except ValueError as e: | ||
return jsonify({"error": "BadRequest", "message": str(e)}), 400 | ||
sentry_sdk.capture_exception(e) | ||
return jsonify({"error": "BadRequest", "message": "Invalid request data."}), 400 | ||
except Exception as e: |
"product_id": e.product_id | ||
}), 409 | ||
except ValueError as e: | ||
return jsonify({"error": "BadRequest", "message": str(e)}), 400 |
Check warning
Code scanning / CodeQL
Information exposure through an exception Medium
Stack trace information
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
To fix the issue, we will replace the direct use of str(e)
in the response with a sanitized and generic error message. This ensures that no sensitive information is exposed to the user. Specifically:
- Replace the
str(e)
in theValueError
handler with a generic message like"Invalid input provided."
. - Log the original exception message (
str(e)
) for debugging purposes usingsentry_sdk.capture_exception(e)
or another logging mechanism.
This change will ensure that sensitive information is not exposed to the user while still allowing developers to debug the issue using the logs.
-
Copy modified lines R97-R98
@@ -96,3 +96,4 @@ | ||
except ValueError as e: | ||
return jsonify({"error": "BadRequest", "message": str(e)}), 400 | ||
sentry_sdk.capture_exception(e) # Log the original exception | ||
return jsonify({"error": "BadRequest", "message": "Invalid input provided."}), 400 | ||
except Exception as e: |
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.
InsufficientInventoryError
exception for better error management.process_order
to handle cart items and quantities separately, validating product IDs and quantities.This fix was generated by Seer in Sentry, triggered automatically. 👁️ Run ID: 61612
Not quite right? Click here to continue debugging with Seer.