CheckoutGuard repair record
Expired coupon must be rejected
Repair fix_c4c0c1d1a9 · attempt 1 · branch cg/expired-coupon-c4c0c1d1a9 · 2026-11-25T08:42:51.924Z
✓ Verified: the same journey passed after the patch. A person discarded the patch instead of merging it.
1. The failure
Kane CLI run run_e7b5802230
Kane: an error message says the coupon has expired and no discount is applied
Expected an error message says the coupon has expired and no discount is applied, the page showed The cart accepted OLD20 and applied a 20% discount instead of showing that the coupon had expired..
- ✓ Kane: navigate: Navigate to http://127.0.0.1:56960
expected step completes · actual done - ✓ Kane: click: Clicking Add to cart for the Canvas Tote
expected step completes · actual done - ✓ Kane: wait: queued plan (2 steps): type "Coupon code"; click "Apply coupon"
expected step completes · actual done - ✓ Kane: type: Type "OLD20" into "Coupon code"
expected step completes · actual done - ✓ Kane: click: Click "Apply coupon"
expected step completes · actual done - ✓ Kane: wait: PRIMARY: wait 500 ms after applying the coupon
expected step completes · actual done - ✓ Kane: analyze: no discount is applied.
expected step completes · actual done - ✗ Kane: an error message says the coupon has expired and no discount is applied
expected an error message says the coupon has expired and no discount is applied · actual The cart accepted OLD20 and applied a 20% discount instead of showing that the coupon had expired. Kane's diagnosis: The coupon check treated OLD20 as valid even though this test requires it to be expired.
Fix the coupon rules so OLD20 is rejected as expired, show a clear expired-coupon message, and leave the cart total undiscounted.
evidence: objective_contradiction: Coupon OLD20 applied: 20% off (25.0 Kane credits)
2. The patch
Made by the coding agent in an isolated git worktree. Only files under store/src/ may change.
diff --git a/store/src/pricing.js b/store/src/pricing.jsindex ee3422e..7a238bf 100644--- a/store/src/pricing.js+++ b/store/src/pricing.js@@ -16,6 +16,10 @@ export function subtotal(lines) { export function checkCoupon(code, today = new Date()) { const coupon = COUPONS[String(code || "").trim().toUpperCase()]; if (!coupon) return { ok: false, reason: "That coupon code doesn't exist" };+ // Valid through the end of its expiry date (compared as YYYY-MM-DD, UTC).+ if (coupon.expires && today.toISOString().slice(0, 10) > coupon.expires) {+ return { ok: false, reason: `That coupon expired on ${coupon.expires}` };+ } return { ok: true, percentOff: coupon.percentOff }; }
3. Unit checks
Unit checks: 3 passing, 4 failing.
Newly passing: expired coupons are rejected and give no discount
Newly failing: none
4. The same journey, rerun
Kane CLI run run_e615db2a42: passed
- ✓ Kane: navigate: Navigate to http://127.0.0.1:57461
expected step completes · actual done - ✓ Kane: click: Clicking Add to cart for the Canvas Tote
expected step completes · actual done - ✓ Kane: wait: queued plan (2 steps): type "Coupon code"; click "Apply coupon"
expected step completes · actual done - ✓ Kane: type: Type "OLD20" into "Coupon code"
expected step completes · actual done - ✓ Kane: click: Click "Apply coupon"
expected step completes · actual done - ✓ Kane: analyze: no discount is applied
expected step completes · actual done - ✓ Kane: assert: an error message says the coupon has expired and no discount is applied
expected step completes · actual done - ✓ Kane verified: an error message says the coupon has expired and no discount is applied.
expected assertion holds · actual applied an expired coupon to the Canvas Tote cart on the cart page (16.1 Kane credits)
Before and after
Before

After

Generated by CheckoutGuard. Payments in the demo store use a fake provider; nothing was charged.