A default is a decision I didn't know I was making
I shipped a feature, then ran a review against it on purpose — and it found the one line I'd written without thinking.
By Andrew Pyle
The worst line in the feature was the one I never thought about: a sort order that defaulted to zero.
01Shipped, then reviewed
I reviewed it after it was already live
I built a small control this week: a page where I drag the standalone sites in my network into the order I want them to appear. The backend stores one number per site, the list sorts by that number, and the public page reads the result. It is the kind of feature that is done in an afternoon and feels finished because the tests are green and the thing visibly works.
Then I did something I do not do often enough: I ran a review against it on purpose, after it had already merged. Not a quick glance at the diff, but a deliberate adversarial pass whose only job was to assume I had made a mistake and go find it. I pointed it at the code that was already in production.
Reviewing shipped code feels backwards. The decision is made, the branch is gone, the dashboard is green. But green only tells you the thing you asked about passed. It says nothing about the questions you never wrote down.
02The line I never thought about
Zero is not neutral
The finding was embarrassingly small. The sort-order column defaulted to zero. When I reordered the sites I cared about, they got the numbers one, two, three, and so on. Fine. But every site I had not touched — and, more importantly, every site I would add in the future — kept the default. Zero.
Zero sorts first. So the moment I launch a new site and mark it live, it does not land quietly at the bottom of the list where a brand-new, unranked thing belongs. It jumps to the very top of the public preview, ahead of the order I deliberately set. The feature whose entire purpose was to let me control the order would, left alone, silently override me every time I shipped something new.
I had not decided that new sites should lead. I had just typed `default=0` because zero is what you type. The fix was one character of intent: default to the maximum value instead, so an unranked item sorts last until I say otherwise. But the bug was never really the number. It was that I let the field have an opinion I never gave it.
03The habit, not the patch
Make the quiet decisions loud
Every default is a decision. The empty string, the zero, the `true`, the retry count of three — each one is a choice about what happens in the case you did not name, which is usually the case that shows up later in front of someone who is not you. You can make that choice on purpose, or you can let the keyboard make it and find out in production.
What actually caught this was not cleverness. It was pointing a second pass at work I had already called done, and grounding that pass in the specific mistakes I have made before rather than a generic checklist. A review that knows your history asks the question you personally keep forgetting. Mine, apparently, is: and what happens to the next one you add?