Stock Reservation Response Never Checked in order_service - Team 177
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia in app.py, nella funzione create_order(), includendo il controllo delle scorte intorno alle righe 152–160, e segui il POST all’endpoint /reserve del product service. Verifica come vengono gestite le risposte di prenotazione e gli elementi prenotati in precedenza; il lavoro è completato quando le risposte diverse da 200 producono l’errore indicato, rilasciano le prenotazioni precedenti e non creano né pubblicano l’ordine come riuscito.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
Imagine you're buying concert tickets online. You click "Reserve," but the system never actually checks whether the tickets were held for you. it just assumes they were and charges your card anyway. That's essentially what's happening here.
In create_order(), the code loops through each item and fires off a POST request to the product service's /reserve endpoint. But after making that call, it completely ignores whether the reservation actually succeeded. It blindly adds the item to the reserved list and keeps going. A 409 (Insufficient Stock), a 500 (server error), or even a 400 (bad request). All silently treated as success.
What happens step by step:
- User orders 10 units of Product A (only 3 in stock)
- The earlier stock check (lines 152–160) passes because it reads current stock — but another request could have consumed stock in between (race window)
- The /reserve call returns
409 Insufficient Stock - The code doesn't check
resp.status_code. it just appends to reserved anyway - The order gets created in the database as PENDING with total_amount calculated
The customer now has an order for 10 units that were never actually reserved- The SQS event fires saying the
order was created. Downstream systems think it's real
In short = User get all 10 products, no matter those products are in stock or not.
Expected Behavior
After calling /reserve, the code should check resp.status_code. If it's anything other than 200, it should:
- Roll back any items already reserved (release them)
- Return a meaningful error to the caller
POST /api/v1/orders
→ 409: { "error": "Not enough stock for product 'Laptop'" }
Location
app.py
Impact
- Overselling: Orders get created for products that aren't actually reserved.
- Customers see a confirmed PENDING order, but there's nothing backing it in inventory. When they try to pay or you try to ship, the stock isn't there.
- No error is logged, no alert fires. Everything looks fine in the order table while inventory is slowly drifting out of sync.
Suggested Solution
With the perfect status logic of handling the checking process and comformation of order list at the same time.
- Lingua principale
- Python
- Stelle
- 3
- Fork
- 8
- Merge medio
- 1h 6m
- PR unite (30g)
- 3
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di keploy/ecommerce_sample_app
-
Improve and restructure README documentation for better clarity Issue 161Forse già presa @Jerry-145 l’ha presa 243 giorni fa. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Hardcoded Credentials Security Issue T152Forse di nuovo libera @Talaviya-Sarthak l’ha presa 244 giorni fa e non c’è nessuna pull request aperta. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 32/100
keploy/ecommerce_sample_app#7 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 55/100
keploy/ecommerce_sample_app#5 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
keploy/ecommerce_sample_app#4 · 1 commento ·
Tutte le issue di keploy/ecommerce_sample_app
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Arekkazu/sgpmp-backend#744 ·
I maintainer di solito rispondono entro 1 giorno
-
Review backlog (security): master-branch remote guard trusts unbound provenance package fieldApertaagent/reviewer
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
projectbluefin/utah-packages#634 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue help wanted
Difficoltà 2/5 1-2 giorni Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
home-assistant/core#188613 ·
I maintainer di solito rispondono entro 1 giorno
-
WebsiteApertagood first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 91/100
TanbirRamim/open-source-radar#314 ·
I maintainer di solito rispondono entro 1 giorno