---
title: "Three bugs only a gate would have found"
description: "All three had been shipping for weeks. None produced an error, a warning or a failed build. Each was found by measurement, not by anyone looking."
url: https://laurens.ai/writing/three-bugs-only-a-gate-would-find
canonical: https://laurens.ai/writing/three-bugs-only-a-gate-would-find
author: "Lawrence Dauchy"
authorUrl: https://www.linkedin.com/in/vibecoding/
published: 2026-08-20
updated: 2026-08-20
category: "Building"
tags: ["continuous-integration", "testing", "gates", "performance-budgets"]
lang: en
---

# Three bugs only a gate would have found

> **In short.** Bugs that produce no error are the expensive ones, because the feedback loop that would normally catch them never fires. Three from one codebase: a CI budget check that could never pass, a CI runtime two major versions behind what the project required, and a validation rule that compared a value against itself. The common thread is that all three looked like working checks, and none of them was measuring what it claimed to measure.

I spent an evening converting a site's build system, and the conversion itself went fine. What did not go fine, and what the evening was actually worth, was the three bugs the conversion exposed. All three had been in production for weeks. None of them had produced an error, a warning, or a single line in any log.

I want to write them up specifically, because the interesting thing is not any individual bug. It is that all three belonged to the same category: a check that looked like it was working, and was not measuring what it claimed to.

## The budget that could never pass

The repository has a JavaScript weight budget. The site loads a 3D scene behind an explicit user action, so the deal was: the lazy chunk can be as heavy as it needs to be, and the code that runs before the visitor asks for anything stays small. That is a real constraint and worth enforcing.

The CI step enforcing it looked like this:

```
BYTES=$(gzip -c dist/assets/*.js | wc -c)
test "$BYTES" -le 40960
```

Read it quickly and it is obviously fine. Gzip the JavaScript, compare against 40 kB, fail if over.

Read it again. The glob expands to every JavaScript file in the directory. `gzip -c` with multiple filenames concatenates them and compresses the lot as one stream. So `BYTES` was the compressed size of the entry chunk *plus the lazy 3D chunk*, which is most of a 3D library, against a 40 kB limit.

That is roughly 166 kB compared to 40,960 bytes. The step could not pass. It had never passed since the lazy chunk was introduced.

Which raises the obvious question: why was CI green?

It was not. The workflow had been failing on that step, and the failure had become part of the scenery. Nobody was reading a red mark they had already decided was noise. That is the actual bug, and the shell mistake is only how it started.

The fix was not to correct the arithmetic. It was to delete the step and call the budget script that already existed in the repository, which measures each chunk separately against its own limit and prints both numbers. Two lines of shell doing arithmetic on the wrong quantity had been standing in for a tool that was already there.

**The generalisable version:** a check that has never passed is not a check. It is a permanently red light that trains everyone who sees it to stop looking. The first thing to establish about any gate is that it is capable of both outcomes.

## The runtime two versions behind

The same workflow pinned its Node version like this:

```
node-version: '22'
```

The project's `package.json` said `"engines": { "node": ">=24" }`. The `.nvmrc` said 24. Local development was on 25.

That gap had already cost a production deploy earlier in the year. The build script imports a TypeScript module directly and relies on the runtime stripping the types, a capability that arrived recently and behaves differently across versions. When the host's build image picked an older runtime, the build died in a way whose error message pointed at the importing file rather than at the runtime, and the first two attempts to fix it went looking in the wrong place entirely.

After that incident, `engines` and `.nvmrc` were both set correctly. The CI workflow was not updated, because the incident happened during a deploy and CI was not what anyone was looking at.

So the repository ended up in the state where its own continuous integration ran a configuration the project declared unsupported. CI was, in a real sense, testing a different project.

**The generalisable version:** when you fix a version mismatch, fix it in every file that states a version, and grep for the number rather than trusting your memory of where it appears. A version constraint declared in three places and honoured in two is worse than one declared nowhere, because it looks handled.

## The check that compared a value to itself

This is the one I am least pleased about, because I wrote it that evening, and it went in as part of the work that found the other two.

The site's canonical URL is derived from a single constant so it cannot be typed twice. Good. To make sure the built page actually emits it, I added a rule to a gate that reads the built HTML:

```
require(
  html.includes(`<link rel="canonical" href="${CANONICAL}">`),
  `canonical must be exactly ${CANONICAL}`,
);
```

The gate imports `CANONICAL` from the same module the page renders it from.

So: break the constant, and the built page emits the broken value, and the gate's expectation becomes the broken value, and both sides move together, and the check passes. It could report a failure only if the head component stopped rendering the tag at all. Every other way of getting the canonical wrong was invisible to it.

I found this because I was proving the gate could fail. I changed the origin to a nonsense value, rebuilt, and watched it pass. That is a deeply unpleasant thirty seconds and I recommend it to everyone.

The corrected rule writes the expected origin as a literal, in the gate, duplicated from the constant on purpose:

```
const EXPECTED_CANONICAL = 'https://example.com/';
require(CANONICAL === EXPECTED_CANONICAL, ...);
const canonical = /<link rel="canonical" href="([^"]+)"/.exec(html)?.[1];
require(canonical === EXPECTED_CANONICAL, ...);
```

Duplication is normally the thing you are trying to remove. In a validation rule it is the entire mechanism. A test that derives its expected value from the code under test is not testing, it is agreeing.

While fixing it I added the check that was actually missing: that `og:url` and the canonical, both read out of the built HTML, are equal to each other. Two answers to "what is the address of this page" is a real failure with real consequences, and it was not covered by anything.

**The generalisable version:** a gate must not import its expectation from the thing it is checking. If you cannot state the expected value independently, you do not have a check, you have a tautology with a good name.

## What these have in common

None of the three produced an error. None would have been found by reading the code, because all three read correctly. The shell one-liner looks like it gzips JavaScript. The version string looks like a version. The canonical rule looks like it compares two things.

They were found by three different mechanisms, and it is worth naming them because they are the mechanisms available:

The budget bug was found by **replacing a homemade check with a real one** and noticing the numbers disagreed. The version bug was found by **reading a config file against another config file** during a migration that forced both open. The canonical bug was found by **deliberately breaking the rule to watch the gate fail**, which is a step I now consider mandatory and did not before.

That third one has become a rule for me. A gate is not finished when it passes. It is finished when it has been shown to fail for the reason it exists, and then shown to pass again. It takes about a minute and it is the only evidence that the gate is connected to anything.

## The fourth bug, which no gate would have found

For balance, one that a gate could not have caught, because the boundary matters.

The same repository had, for a while, a claim on a page that was traceable only to a private note. Not false, as far as I know. Just not supported by anything a reader could check. No script can find that. A gate can verify that every number on the page carries a source field, which this repository does enforce, and it cannot verify that the source says what the number says.

That is the honest limit. Gates catch mechanical failures: a value that is wrong, a file that is missing, a budget that is exceeded, a structure that is malformed. They catch nothing about whether a claim is true, whether an argument holds, or whether a sentence means what its author intended.

The failure mode to avoid is letting a wall of green checks stand in for judgement about the things they do not measure. A repository with good gates can still publish something wrong; it just cannot publish something broken. Knowing which of those you have protected against is the whole point of writing the gates yourself rather than installing a preset.

## Choosing which ones to write

Given that you will write a handful and not fifty, the selection matters more than the implementation. The filter I use has three parts.

**Would the failure be silent?** This is the strongest signal. Anything that throws an error, fails a build, or renders visibly wrong will be found by ordinary work. Spend the effort on the failures that produce nothing: a byte budget creeping past its limit, a heading structure quietly degrading, an anchor renamed in a refactor.

**Is the correct value knowable independently?** If you cannot state the expected outcome without consulting the code under test, you will write a tautology. That is the canonical bug above, and it is easy to write without noticing.

**Would I actually be told?** A check whose output goes into a log nobody reads is not a check. It has to fail the build, or it has to print two numbers on every run so a trend is visible. The budget script in this repository prints each chunk's size on every build for exactly that reason: the failure threshold catches a violation, and the printed number catches the approach.

There is a fourth question, which is about cost. A gate that fails on every honest change teaches people to raise its threshold, and a threshold that has been raised twice is decoration. When I raised the entry budget in that repository to accommodate genuinely new content, I wrote the reason into the file and stated the condition under which it had to come back down. It came back down two commits later. Without that note it would not have, because the number would have looked like a decision rather than a loan.

## The version I would actually recommend

If you work alone, the two things that normally catch this class of bug are absent. There is no reviewer with fresh eyes, and there is nobody who will mention that something looks off. What replaces them is measurement written into the build, and the honest constraint is that you will only write a handful of these, so they should be the ones that catch failures nothing else can see.

The ones earning their place in this repository, after that evening:

- **Byte budgets per chunk**, measured compressed, each against its own limit, printing both numbers on every run so a slow creep is visible before it is a violation.
- **Structural assertions about the built page**: exactly one top-level heading, no skipped heading levels, and every URL fragment that has ever been publishable still present. That last one has the longest memory of anything in the repository. A fragment someone saved is a link you cannot see break.
- **A behavioural probe for a thing that was deliberately removed.** The client used to rebuild the page over server-rendered markup. Deleting that call is one careless edit away from being undone, and nothing about the page would look wrong. So a test watches for it directly and fails if it ever happens again.

That last pattern is the one I would push hardest. When you remove something for a reason, the removal is a decision that has to survive people who do not know the reason, including you in six months. A comment explains it. A test enforces it.

The three bugs above cost, between them, one failed deploy, an unknown number of ignored red CI runs, and a validation rule that spent its entire life agreeing with itself. Every one of them was cheap to fix and expensive to find, which is the defining shape of this category and the reason it is worth building the machinery that finds them.

## Sources

- [Node.js: running TypeScript natively](https://nodejs.org/api/typescript.html). The type-stripping behaviour that made the runtime version load-bearing
- [GitHub Actions workflow syntax](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax). How `node-version` is resolved, and why a major-version string is not a pin
- [web.dev: Core Web Vitals](https://web.dev/articles/vitals). The metrics worth putting a budget on, and the ones that are not measurable headlessly
- [Playwright test assertions](https://playwright.dev/docs/test-assertions). The assertion library the probes in this article are written against

## Questions this answers

**Is a gate just a test?**

A test asserts that code does what it should. A gate asserts that a property of the whole artefact still holds: a byte budget, a heading structure, an anchor that must never move. Tests protect behaviour, gates protect the things that have no behaviour to observe.

**How do you know a gate works?**

Break the rule on purpose and watch it fail, then restore it and watch it pass. A gate that has never failed has never been shown to be capable of failing, and several of the ones in this article looked exactly like working gates.

---

Source: https://laurens.ai/writing/three-bugs-only-a-gate-would-find
Markdown: https://laurens.ai/writing/three-bugs-only-a-gate-would-find.md
Author: Lawrence Dauchy
Free to quote and cite with attribution and a link.
