I shipped a CI path filter that never filtered anything, and I closed the ticket without checking a single run
This is a write-up of a mistake I made. I’m posting it because the mistake itself was small and ordinary, but the way it stayed hidden is worth looking at.
The problem I was supposed to fix
Our superrepo holds every component as a submodule, plus a few trees of its own: deployment config, a local dev stack, CI gates, and a documentation site. One pipeline validates every pull request. That pipeline ran every gate on every PR: shell tests, the Python suite, a browser rendering parity check, and every docs build. Changing one line of one script cost close to an hour of CI time.
The fix was supposed to be simple. Add a step at the start of the job that lists the paths the PR changes, and run each gate only when the PR touches files that gate reads. Pushes to the protected release branches would still run everything.
I wrote that step. It landed and the ticket was closed as done. For the next day and a half it skipped nothing. Each PR validation ran the full suite, and the median run time didn’t move at all.
What I wrote
To find what a PR changed, the script needed a merge base between the PR and its target branch. The pipeline checks out the PR’s merge commit at depth one, so the script fetched the target branch shallowly and then ran git fetch --deepen in a loop until a merge base showed up.
Our hosted git server doesn’t support --deepen. The first deepen call failed every time:
fatal: Server does not support --deepen
fatal: the remote end hung up unexpectedly
the history of the target branch could not be deepened, so every gate runs
That last line came from my fallback. Simplified, it looked like this:
run_every_gate() {
echo "$1, so every gate runs"
for name in "${gates[@]}"; do
set_variable "$name" true
done
exit 0
}
It printed a plain echo, turned every gate on, and exited 0. The step showed green, every gate ran, every gate passed, and the run looked exactly like it did before my change. Nothing showed it was broken unless you opened the step’s log and read it.
Why my tests didn’t catch it
My test suite built its fake remote with git init in a temp directory and cloned from that local path. One test case was called “a merge base beyond the first fetch is found by deepening”, and it passed. A local-path remote supports --deepen, so I had tested a protocol that production doesn’t offer.
Why review didn’t catch it
The ticket’s acceptance criteria included this line: the pull request’s own validation runs only the gates its change names, as its run shows.
Nobody read the run, and that includes me. My PR touched the pipeline definition, the CI scripts, and the CI tests, so a working filter would have run every gate on it anyway. On that one PR, working and broken looked the same in the run times. The fallback line in the log was the only evidence, and I didn’t look at it.
Then it spread. I updated the CI docs to say the mechanism worked. A follow-up ticket was filed to extend the design, and it kept the deepen approach. Some of the work that came after mine was built on the assumption that mine worked.
It also wasn’t the first warning. The same week, another project reported a selection mechanism that was present but did nothing, for a different reason. If I had read that report and asked whether ours had the same problem, one log read would have found this a day earlier.
What I should have done
Read the run. If the acceptance criteria say “as its run shows”, I should open the run, read the decision step’s log, and quote it when closing the ticket. When the PR itself touches the pipeline and can’t demonstrate the behavior, the evidence is the first ordinary PR after the merge, and the closing note should link to it.
Make the fallback loud. If a mechanism’s failure mode is “do everything, like before”, you can’t tell working from broken unless the failure announces itself. The fallback should raise a pipeline warning that shows on the run summary, or fail the step. It should never be a quiet echo followed by exit 0.
Design for the forge, not for git’s manual. A PR validation already checks out the merge commit, and that commit’s first parent is the target branch’s head. Diffing the merge commit against its first parent gives you the changed paths, and you only need to fetch the merge ref at depth two. No merge-base search, no deepening, and nothing that depends on a server capability. Once someone asked, this approach was written up in minutes. I should have checked what the server supports before building on a feature it doesn’t.
Make the test fixture refuse what production refuses. The test needs a case where --deepen fails, using a stub git on PATH or a git daemon with shallow operations turned off, and it should assert that the failure is reported loudly. A fixture that’s more forgiving than production is testing a different system.
Close a performance fix against the number that motivated it. The original complaint was hour-long runs on trivial changes. The ticket should have closed with “here’s a one-file PR after the change, and here’s its run time next to the old one.” If the median doesn’t move on the day the fix lands, the fix didn’t work.
What I’m changing
- Before I close a ticket for an observable behavior change, I link to a real run that shows the behavior. Green tests aren’t enough.
- Every fallback I write to “the old behavior” emits a warning on the run. Silent degradation counts as a bug.
- Before relying on a git feature in CI, I check that our hosted server supports it. My tests now fake the server’s refusals.
- When another team reports a failure, I take a few minutes to check whether the same thing applies to us.
The changed-paths step is being rewritten to use the merge-commit diff, with a loud failure path. I’ll update this post with the first real run’s numbers once it lands.