1
0 Comments

The bug that taught me to stop trusting my own code reads

A user hit a bug where a documented API field did nothing. No error. The request succeeded and the data just never showed up.

Cause: we had one input schema declared in two places. A Zod schema validating one deployment path, a hand-written JSON Schema describing the other. Zod deletes unknown keys by default, so once the copies drifted, one path silently threw away fields the other path accepted.

I read both files side by side, carefully, twice, and found 6 drifted fields. Then I wrote a small test that imports both schemas and diffs their key sets. It found 13. One of them was being stripped in production and nobody had noticed, because stripping looks like success.

The best part: that file already had a comment saying "keep both copies in sync." It supervised all 13 drifts without lifting a finger.

Two lessons I'm keeping. If a bug is "two lists must match," write the diff as a test and let it enumerate the damage, because my eyeballs found less than half. And any validator that strips unknown input is an allowlist that deletes things, not a safety net.

on August 20, 2026