I shipped a chart that hid the one thing it existed to show
Last week I shipped a run-duration chart for our pipeline page that was wrong in two ways at once, and the two ways covered for each other well enough that nobody noticed for a while. I want to write down what happened, because the mistake wasn’t a typo or an off-by-one. It was a sequence of small moments where I saw something odd and chose to keep typing.
What the chart was supposed to do
The idea is simple. For each pipeline, draw one bar per recent run showing how long it took, and draw a dashed line at the “usual” duration (a median over recent runs). A run that is unlike the others should jump out: a bar that’s much taller or shorter than the line. Failed runs get their own color so you can tell a slow failure from a slow success.
What I actually built
The spec I was working from said the median should be taken over runs that ended in the window, and that failed runs should be drawn in their state’s color. I implemented exactly that.
The problem is that “ended” isn’t one outcome. In our system a run can end by succeeding, by failing, or by being cancelled. So:
-
The median included cancelled runs. A cancelled run is, by definition, one that didn’t finish. An early failure is cut short too. Both pull the median down. On one of our busier pipelines, the “usual” duration read about 36 minutes while a normal green run took 52. Every successful run looked like an outlier, and the reference line marked nothing useful.
-
The chart drew passed and cancelled runs in the same grey. The spec called out failed runs for a color and said nothing about the other two, so I split the data into “failed” and “everything else” and painted “everything else” one neutral color. A passed run that finished suspiciously fast looked identical to a run someone cancelled thirty seconds in. You had to click each short bar to find out which it was.
And here’s the part I keep coming back to: when I wrote the legend for that grey series, I labeled it “Passed or cancelled.” I literally typed the word “or” between two distinct outcomes, looked at it, decided it was accurate, and moved on. I noticed the lump. I just named it instead of questioning it.
Why the tests didn’t save me
They couldn’t have. I wrote them from the implementation rather than from the problem.
- The backend test for the median built every fixture run as a success. The statistic was never computed over a mix of outcomes, so a missing state filter was invisible.
- The frontend model test had one cancelled run in it, but that run had no duration, so it was dropped before the chart ever saw it. No test placed a cancelled run with a real duration on the chart, which is the only situation where the lumping shows.
Both suites just reflected my own assumptions back at me and passed.
Why it took a while to notice
The two defects masked each other. Because cancelled runs were in the median, the line sat low enough that short grey bars didn’t look out of place. Because the grey mixed cancelled and passed runs, nothing on screen hinted that the line was wrong. Fix either one alone and the other would have been obvious within a day.
What I should have done
Asked what the number is for before computing it. “Median of durations” is unfinished until you say which runs count. The statistic exists to answer “how long does a run take when it does its job.” A run that didn’t do its job isn’t an instance of that. Thirty seconds of thought at the point of writing the query would have gotten there. There was already a state filter in that same module for a different feature; adding one would have cost nothing.
Treated the spec’s silence as a question, not a permission slip. The spec named one state out of a known set of three and said nothing about the other two. That’s not a decision I was free to make by default; it’s a gap. The right move was a short note back to the author: “You colored failed runs. What about cancelled? Do they belong in the median?” The answer was never in doubt, and the conversation would have taken five minutes.
Stopped when I wrote a label with “or” in it. This is the lesson I’m most embarrassed by, because the signal was so loud. If a legend entry, column header, or filter name has to join two states with a disjunction, the UI is admitting that it’s throwing away a distinction the data already carries. That moment is a design smell, not a copywriting problem. The fix is never a wider label.
Built test fixtures from the state enum, not from the happy path. For anything that draws or aggregates over outcomes, the minimum fixture is one item per outcome, each with real data, asserting where each one lands and whether each one moves the aggregate. If the design defines six states and the tests exercise one, the tests aren’t about the feature.
Sketched the expected picture first. If I’d drawn, even on paper, what a correct chart should look like (green bars clustered around the line, red and grey bars short and scattered below it) then the actual result (everything grey, line sitting under most of the bars) would have been recognizably wrong without reading a single value.
The general version
I’m trying to carry a few rules forward from this:
- A summary statistic is defined by its population, not just its formula. Before averaging anything, state what the number means and check that every member of the population is an example of that thing. Incomplete, aborted, skipped, and timed-out items almost never are.
- When a spec treats one value of an enum specially and is silent on the rest, the silence is a defect. Either raise it or write down the decision about the others explicitly.
- A UI that collapses a distinction the data holds has made a choice. That choice needs a reason written down. If I can’t articulate the reason, I shouldn’t be merging.
- “I implemented what it said” is not a defense when what it said is incoherent on its face. If I can see that a cancelled run shouldn’t lower a “usual duration,” I’m expected to say so before building it, not after.
The fix itself was small: filter the median to successful runs, give each outcome its own color, and add the fixtures that should have been there from the start. The lesson is about the three or four moments where I noticed something and decided it wasn’t my problem. It was.