Fix 500 - Internal Server Error in checkout flow (FRONTEND-REACT-6CS)#1387
Draft
cursor[bot] wants to merge 1 commit intomasterfrom
Draft
Fix 500 - Internal Server Error in checkout flow (FRONTEND-REACT-6CS)#1387cursor[bot] wants to merge 1 commit intomasterfrom
cursor[bot] wants to merge 1 commit intomasterfrom
Conversation
- Backend: Move quantities definition before usage in /checkout endpoint - Frontend: Fix inverted error-checking logic in CheckoutForm.jsx
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project check has failed because the head coverage (22.10%) is below the target coverage (35.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## master #1387 +/- ##
==========================================
+ Coverage 22.01% 22.10% +0.09%
==========================================
Files 42 42
Lines 1363 1357 -6
Branches 176 173 -3
==========================================
Hits 300 300
+ Misses 1036 1030 -6
Partials 27 27
*This pull request uses carry forward flags. Click here to find out more.
|
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.
Summary
Fixes FRONTEND-REACT-6CS: Resolves 500 Internal Server Error occurring during checkout submission.
Root Cause
The issue had two components:
quantitiesvariable was accessed before being defined in the/checkoutendpoint (line 225), causing aNameErrorthat resulted in a 500 responseChanges Made
Backend (
flask/src/main.py)quantitiesdefinition from line 228 to line 225quantities = {int(k): v for k, v in cart['quantities'].items()}is executed beforelen(quantities)checkFrontend (
react/src/components/CheckoutForm.jsx)if (!response.error || response.status === undefined)toif (response.error)response.errorexists) → capture to Sentry without throwingresponse.erroris undefined) → throw error to trigger navigation to error pageTesting
The fix ensures:
/errorpage on checkout failures