Field note · April 23, 2024
The `else` branch that ate 4% of revenue
A new payment type, a forgiving CASE statement, and six weeks of quietly wrong numbers.
The payments team added buy-now-pay-later. New value in the payment_type enum. They shipped it on a Tuesday and did not tell us, because they had no idea we read that column.
Downstream:
case
when payment_type in ('card', 'wallet') then revenue_usd
when payment_type = 'cash' then revenue_usd * 0.98
else 0
end as net_revenueEvery BNPL order contributed zero. It started at 0.4% of orders and grew. Net revenue drifted below where it should be by an amount that stayed inside normal weekly noise for a month.
Nothing failed. Row counts were right — the rows were all there, containing zeros. Uniqueness passed. Not-null passed. Freshness passed. Someone remarked that growth "felt soft".
Found in week six by a finance analyst reconciling manually for an unrelated reason.
The six controls that each would have caught it independently, and we had none:
- An accepted-values test on
payment_type. - An
elsethat fails instead of returning zero. - Category-proportion monitoring — the share landing in
elsewent 0% → 4%. - Scheduled reconciliation against billing.
- A contract with the payments team.
- Taking "feels soft" seriously as a bug report.
We now have all six. The general lesson is the one I keep coming back to: silent failures always live in a default. Audit your else branches, your coalesces, your fillna(0)s. A default never raises an error. It just produces a plausible number.