Someone with write access to sentry-demos/empower needs to apply this fix to resolve the HTTP 500 error in the checkout endpoint.
# Clone the empower repository
git clone https://github.com/sentry-demos/empower.git
cd empower
# Create fix branch
git checkout -b error-500---wxj3au
# Download and apply the patch from this PR
curl -o fix.patch https://raw.githubusercontent.com/sentry-demos/sentry_react_native/error-500---wxj3au/BACKEND_FIX.patch
git am fix.patch
# Push to remote
git push -u origin error-500---wxj3au
# Create PR to merge to master-
Open
flask/src/main.pyin the empower repository -
Go to line 225
-
Find these lines:
if len(quantities) == 0: raise Exception("Invalid checkout request: cart is empty") quantities = {int(k): v for k, v in cart['quantities'].items()}
-
Change to:
quantities = {int(k): v for k, v in cart['quantities'].items()} if len(quantities) == 0: raise Exception("Invalid checkout request: cart is empty")
-
Commit and push:
git add flask/src/main.py git commit -m "fix: Move quantities assignment before usage in checkout endpoint Fixes MOBILE-REACT-NATIVE-4S" git push
After applying:
- Deploy the Flask backend to staging/production
- Open the mobile app
- Add items to cart
- Tap "Submit Checkout"
- Verify HTTP 200 response (not 500)
- Check that no
UnboundLocalErrorappears in logs
The code was checking len(quantities) before quantities was defined, causing Python to raise UnboundLocalError. Moving the assignment before the check ensures the variable exists before it's used.
If you need help applying this fix, refer to:
- Full documentation:
BACKEND_FIX_MOBILE-REACT-NATIVE-4S.md - Patch file:
BACKEND_FIX.patch - PR: #128