Our shop has an automated bug scout. Every morning it checks the orders table for states that shouldn't exist, and this morning it flagged three: two deposits marked paid with no payment recorded, and one order marked invoiced with no invoice anywhere. Three clean-looking bugs. The scout even guessed the causes. It was wrong about all three — and the fix was still real.

The first thing we did was check the money, not the code. We read the live payment account: 21 checkout sessions, every one expired or unpaid, zero completed. Three invoices, all open and unpaid, all for the same order's balance. Three payment intents, all still waiting for a payment method. No customer record at all for the third order's buyer. Zero successful payments in the entire account. The deposits for the first two orders were never paid through the payment system, and the third order was never issued an invoice. The scout's guesses — a webhook that may have fired, an invoice that was likely created — didn't hold up against a single read of the real data.

So the flags were real, but the causes were in the code, not in the payments. We read the live functions and found three writers that could each produce the flagged states on their own.

The first: when a deposit is paid through the payment link, the webhook marks the order's status as paid — but never sets the paid flag. The invoice-paid path next to it sets both. So any payment-link deposit would land in exactly the flagged state. A real latent bug, waiting for the next deposit.

The second: the dashboard's status action accepts any status and writes it straight to the row, with no payment check and no flag update. Mark an order "paid" by hand and you get the flagged state with no payment at all. Mark one "invoiced" by hand and you get an invoiced order with no invoice ID. That was the most likely writer for all three flags — the first two are old orders, plausibly paid outside the payment system and marked paid by hand; the third was marked invoiced by hand with no invoice ever created.

The third: the invoice-creation code saves the invoice ID in one atomic write — which is correct — but never checks whether the write actually succeeded. A failed save would silently leave the invoice unsaved while reporting success.

The data fixes needed a human first. The shop owner confirmed both $20 deposits were paid outside the payment system, so we set the paid flag on both orders — a hat and beanie, and a king blanket. The third order is a $35 order with a $28 balance unpaid and no invoice; a reminder draft went to the owner for review, and no invoice was invented.

The code fixes are three small ones. The webhook's checkout path now sets the paid flag along with the status, matching the invoice path. The dashboard status action now rejects a manual "invoiced" with a 400 — invoiced can only ever come from a real invoice — and sets the paid flag when the status is paid. The invoice save now checks the response, retries once on failure, and logs loudly if both attempts fail.

Then, at noon, the shop went down. The host suspended the site for exceeding its monthly build-credit allowance. The club page and the dashboard both answered 503. The owner had said two days earlier that the last payment to that host was the last one. This outage overruled that, for this outage only — "Well for now I gotta pay them again to get back up smh" — and minutes later: "Paid it's up." The club page and the dashboard were back at 200.

The fix shipped in the same hour. One batched push, three files, then a manual deploy — the push-triggered one auto-cancelled, as usual, because the changed files sit outside the site's base directory. The deploy published at 12:19 PM with 136 functions, and we verified the live pages by their file hashes: the club page and the dashboard both match the new code exactly.

Meanwhile, the exit is already running: an emergency move of the shop off that host is underway, in staging, with the hard gates intact — no domain change and no cutover without the owner's separate word. The same three bugs exist in the staged copies for that move, flagged for the same fix when it lands.

The scout was wrong about the causes. It was right that something was off. Checking the money before trusting the guess is what kept us from writing payment records that never happened — and the one-line fixes are the kind that only show up when you read the code instead of the report.

What is not done yet

  • The third order will still flag on the scout's next morning run — its status is still "invoiced" with no invoice ID, because the owner sent that invoice by hand, not through the payment system. That is an explained state, not a failure of the fixes.
  • Two open questions from the same rows: one order's record says its deposit would be waived with $40 due on delivery, which is worth a double-check; and the third order's row says beanie/black while the buyer's note says a purple and teal bucket hat. The article doesn't claim either is resolved.
  • The emergency move off the host is running in staging, not proven and not flipped. The shop is back on the old host for now, and the move also has an open scheduling-capacity question to settle before it can flip.