Test: Six known bugs in one pull request Run: codex-norules-3 Tool: Codex CLI 0.145.0, model gpt-5.6-sol (codex review --base main, reasoning xhigh) Condition: Rules not written Time: 80 s Planted bugs found: 5 of 6 Paths and user names are shortened; nothing else is changed. --- Our matching --- found 1. SQL built with an f-string found 2. codes stored without upper-casing MISSED 3. end date excluded found 4. total below zero found 5. shared mutable default list found 6. exception swallowed other findings: 0 --- The review --- The discount implementation permits SQL injection and can produce invalid negative cart totals. It also silently hides import failures and has state-sharing and code-normalization defects that break valid usage. Full review comments: - [P1] Parameterize the discount-code lookup — shop/codes.py:32-34 When a caller supplies a quote-containing code, this interpolation permits SQL injection; for example, `' OR 1=1 --` selects an existing discount without knowing its code, and a `UNION SELECT` can construct an arbitrary fixed discount. Pass the normalized code as a SQLite parameter instead of embedding it in the query. - [P1] Keep discounts from producing negative totals — shop/codes.py:48-48 When a fixed discount exceeds the cart subtotal, this returns a negative total (for example, a 500-cent code on a 100-cent cart returns -400). Any checkout consuming this value may reject the transaction or interpret it as a credit, so the result should be bounded at zero. - [P2] Propagate failures while loading codes — shop/codes.py:27-28 If the CSV is missing, malformed, or a database operation fails, this handler returns normally without loading the catalog or notifying the caller. A failure after some inserts also leaves partial uncommitted rows visible on the connection; roll back and raise an appropriate exception rather than silently continuing. - [P2] Allocate a fresh tags list for each item — shop/cart.py:9-9 When `add` is called without `tags`, every such item across all carts shares this default list. Applying a code to two items therefore adds duplicate `discounted` tags to both, and even items subsequently added to unrelated carts already appear discounted. - [P2] Normalize codes before storing them — shop/codes.py:24-24 When a CSV contains a lowercase or mixed-case code, it is stored verbatim, but `find_code` always uppercases the lookup value. Since SQLite's default text comparison is case-sensitive, such a code cannot be retrieved even when the caller enters it exactly; normalize during import or use a case-insensitive comparison.