Error Context Layer / checkout-api / production / inc_8f21c0

error

Null discount rule at checkout

TypeError Cannot read properties of null (reading 'percentOff')

Status
open
Priority
P1
Events
184
Capture
complete

Context Timeline

Request entry, outbound I/O, local state records, and the throw frame.

request -> I/O -> local state -> throw
1
Request entered the service

POST /checkout/confirm reached checkout-api in iad1.

requestId = req_demo_8f21c0capturedtraceId = d4a7e0b92c315f86a1c9e472b05d683fcaptured
POST /checkout/confirm
2
Request entered checkout
couponCode = "WELCOME10"captured
3
Cart loaded
cart.totalCents = 12600captured
Cart load / postgres.carts / 1 row / 12ms /
4
Discount lookup missed
discountRule = nullcaptured
Discount rule lookup / redis:discount:WELCOME10 / null / 4ms /
5
Tax quote returned
taxCents = 1094captured
Tax quote / https://tax.internal/quote / 200 OK / 31ms /
6
Read percentOff on a null discountRule
const discountCents = Math.round(cart.totalCents * discountRule.percentOff);
discountRulenullcaptured
src/checkout/discounts.ts:88:31

Runtime evidence

Values, bound inputs, I/O records, and throw frame metadata.

complete
Captured locals
discountRulenullcaptured
couponCode = "WELCOME10" / discountRule = null / cart.totalCents = 12600 / customerTier = "standard"
Origin I/O
Discount rule lookupredis:discount:WELCOME10null / 4ms / miss
Bound inputsbody.cartId = "cart_9e3a" / body.couponCode = "WELCOME10" / headers.x-request-id = "req_demo_8f21c0"
Capture completenesscaptured locals / captured args / captured I/O41 KB package / encrypted yes
Trace pathPOST /checkout/confirmDiscount rule lookup: nulldiscountRule = nullsrc/checkout/discounts.ts:88request / I/O / local / stack

Stack trace entry point

The stack identifies where Errorcore attached the context above; it is the entry point, not the full answer.

applyDiscountsrc/checkout/discounts.ts:88:31const discountCents = Math.round(cart.totalCents * discountRule.percentOff);
confirmCheckoutsrc/checkout/confirm.ts:141:18
handleRequestnode_modules/fastify/lib/handleRequest.js:103:11

Request context

LinePOST /checkout/confirmRequest IDreq_demo_8f21c0Status500Regioniad1RoutePOST /checkout/confirmBodyselected checkout keys capturedTraced4a7e0b92c315f86a1c9e472b05d683fSpan7f3a9c01d5e842b6 / parent b61f20c98a3d54e7

Runtime and I/O

Nodev22.14.0Hostiad-checkout-03Release2026.05.08-4f17c2SDK0.9.1Memoryrss 384 MB, heap 121 MBLoop lag17 ms
Cart load

1 row

postgres.carts
ok12ms
Discount rule lookup

null

redis:discount:WELCOME10
miss4ms
Tax quote

200 OK

https://tax.internal/quote
ok31ms

Capture completeness

QualitycompleteLocalscapturedArgscapturedI/OcapturedEncryptedyesPayload41 KB
policy appliedpayload 41 KB