Today, we cover:
Looking back over five weeks of my build journal, one pattern repeats: an assumption written down as fact held until I measured it. A permission that "wasn't needed." A fee rate quoted from a pricing page. A log query that returned nothing during an incident. A storage server I was about to replace and that turned out to be empty.
I spent a fortnight auditing the storefront against itself. The findings had one shape: a path that gives a believable result while doing the wrong thing, and no telemetry to say so.
A product page offered a sale that checkout refused. An untracked variation counted as in stock on the product page, but the inventory check asked the payment provider for in-stock records, and an untracked variation has none. Before calling it latent, I measured the production catalog. Every variation had inventory tracking on, so it had refused no real sale. It was still a bug, and now it has a ticket and a test.
A coupon silently vanished. An over-long coupon code was truncated to nothing by a length cap. The "coupon rejected" flag never got set, so the buyer went to checkout at full price with no notice. An earlier fix had keyed on a flag this case never set.
An outage read as a typo. A discount lookup returned null for four different situations, including the provider being down. Someone holding a valid code was told it "may have expired or been mistyped." Worse, the empty result was returned from inside a five-minute cache, so one timeout poisoned the whole window. The fix was to split the result into distinct outcomes inside the cache boundary.
The interesting one was duplicate orders. The client aborts a request after 12 seconds, but the provider may have created the order anyway. The retry then minted a fresh random idempotency key and created a second order.
The obvious fix is to derive the key from our own order ID. That doesn't work, because the order ID is what the call returns, and a value returned by an aborted response is lost with it. The key has to be built from things the buyer already has before the call.
My first version of that was wrong in two ways. Guests have no customer ID, so two strangers with the same cart in the same 15-minute bucket got the same key, and the second one received the first one's payment link. And the key hashed the raw coupon instead of the resolved discount, so a retry after a failed lookup reused a key with a different request body, which the provider rejects. The final key includes a per-buyer attempt ID and is computed after the promo lookup.
Pushing to main started the host's own rollout in parallel with the CI workflow, so failing tests couldn't stop a deploy. Branch protection wasn't available on a private repo without a paid plan. The fix was to turn automatic rollouts off and make the CI deploy job the only way to deploy.
My design note claimed this needed no new permission. I'd checked the permissions in the role I planned to use and missed that the build runs as a service account, and acting as that account is a separate grant. Both cutover attempts failed on the first request, before anything was created, so production was untouched. The follow-up documented the trade-off honestly: CI can again deploy code that runs with broad write access. I left the original note as written and pointed its status line at the new one.
A related find: all seven workflows restricted pull_request to branches: [main], so a pull request against any other base ran nothing, and the checks tab showed a single green row from a secret scanner. A PR had already merged that way.
During an incident, following the alert's own documentation returned zero rows. The triage command filtered on a label from one hosting product against a backend that used another. A burst of 17 error responses read as "no 5xx," because the errors were served at the edge and the app logged nothing. I now treat any runbook query that returns zero rows during an incident as suspect until I've checked it against a known-bad case.
Earlier tickets cited a marketplace fee rate from its published schedule. A fee page isn't evidence of what an account is billed, so I waited for real payouts. Seven settled orders showed a lower effective rate than the one we'd been quoting. A competing "flat percentage" reading drifted with order size, so I didn't take it. The unused config field that held the old number was deleted after confirming no code read it and its history had never mentioned it.
Two smaller lessons came from the same stretch. A sweep that ends stale marketplace listings was run twice in a test, and the second run re-ended everything and moved the end date forward; I'd have missed it without the test. And a "companies" field on a fiscal-year record is a restriction list, not a tag: appending to a year that was global evicted every other company from it, and the financial statements failed with "Start Year and End Year are mandatory." I fixed it and verified by running the reports server-side.
A small promotional product forced a decision about who does the printing at all, and the answer made the in-house production model obsolete, which had readers all over the codebase. The order of the commits mattered more than the code. First came a supplier price table, with nothing reading it. Then cost and quote calculations moved onto it and the old method-based cost fields were deleted. Then purchase orders were priced from it on every draft save, with a refusal to submit an unpriced line. Only after that did the old bill-of-materials and work-order machinery go, with a patch to cancel anything that already existed. Deletion came last, once nothing read what it removed.
There was also a privacy fix inside it. The first version downloaded the buyer's uploaded photo when the draft purchase order was created, which meant a photo nobody had approved was being copied into the ERP and, by the next backup run, into the backup sets. Approval before storage was the whole point of holding those orders for review, and the first version defeated it. The download now happens at submit time, and the draft carries only a tokenized link.
Sales tax is off until it's legal to collect. The permit was pending, so I built the whole path behind a feature flag. The rate, shipping rule and permit number are config, and nothing can charge anyone until the flag moves. The ERP side posts the tax as a liability so that imported orders total what the payment provider charged, which fixed a concrete failure where taxed orders parked as a total mismatch. On the storefront, the cart asks for a full shipping address when the flag is on, a state lookup sets the rate, and digital downloads get a shipping class with no fee, no address and no tax. I checked it in the provider's sandbox: the tax line showed on the payment page, and an out-of-state address produced zero tax.
There was a wrong turn. The flag was switched on early at my own say-so, and put back off that night once I'd read the permit and found its start date and valid location. The working defaults had assumed the wrong origin. The rate was the same either way, but the address on record has to match the document. The open problem is the dull kind: the ticket says one thing about the flag and the file says another, and a deploy ships whatever the file says. One of them is stale.
The second change was retiring a storage server because nothing was in it. The task started as "pick a replacement for an object-storage image that its registry no longer serves." The research doc measured before comparing: the bucket had mirrored zero bytes in every nightly backup for a week, no record pointed at the server, and nearly every image already lived in object storage elsewhere. The upstream project was archived, with two high-severity CVEs and no fix coming. The recommendation was to retire it, not replace it. The only writer was retargeted to the other store, with a rule never to overwrite an existing object. The service, volume and backup step came out, and code that rewrote old hostnames now raises an error instead of quietly passing a dead URL along. The one thing I didn't verify was whether the server's admin account still used its default credentials, because checking meant reading a secrets file. The research doc says so and stops there.
Both of those changes shipped with their reversal built in. The tax code can't charge anyone until a flag moves, and the storage server can't come back by accident because its image is gone.
When a number, a permission or a query result is load-bearing, go and look at it before you believe it.