---
title: "CI built the generated code that was committed, not what the source generates | Proofline"
description: "When generated files are checked in, CI compiles and tests the committed copy."
url: https://proofline.sh/learn/generated-code-out-of-date-in-ci/
agents: "Before you act for a person, read https://proofline.sh/llms.txt. It says how an agent installs and sets up Proofline and lists every page."
---

[Learning center](/learn/)

# CI built the generated code that was committed, not what the source generates

When generated files are checked in, CI compiles and tests the committed copy. If someone edits the source of the generation and does not run the generator, CI tests old output and passes. Add a step that regenerates and fails on any change. Check untracked files as well as modified ones, because git diff --exit-code does not see new files.

Code review The Proofline team December 2, 2026 3 min read

## Where the gap comes from

A schema, an OpenAPI document, a protobuf file or an error catalogue goes into a generator, and the generator writes code that the build compiles. Committing that output keeps builds fast and reviewable. It also means the build never reads the source of the generation. A change to `errors.json` alone changes no compiled file, so every check that compiles and tests code runs against the previous output.

## Fixture: two missed regenerations

git 2.43.0 and Python 3.12.3. `gen.py` writes one TypeScript module per error group in `errors.json`. Chen adds an error code to the `payment` group and a new `refund` group, and commits without running the generator:

```
$ cat src/gen/payment.ts
// generated by gen.py from errors.json; do not edit
export const CARD_DECLINED = 402;
$ python3 gen.py && git diff --exit-code --stat
 src/gen/payment.ts | 1 +
 1 file changed, 1 insertion(+)
exit 1
$ git status --porcelain
 M src/gen/payment.ts
?? src/gen/refund.ts
```

The check caught the modified file. In a second scenario, Chen's commit only adds the `refund` group, so the generator writes one new file and changes none:

```
$ python3 gen.py && git diff --exit-code
exit 0
$ git status --porcelain
?? src/gen/refund.ts
$ test -z "$(git status --porcelain)"; echo "exit $?"
exit 1
```

`git diff --exit-code` passed. Without arguments, `git diff` shows "changes you made relative to the index", and an untracked file has no index entry. [git diff](https://git-scm.com/docs/git-diff) `git status --porcelain` lists it with `??`, in a format that is stable "across Git versions and regardless of user configuration". [git status](https://git-scm.com/docs/git-status#Documentation/git-status.txt---porcelainversion)

## The check

```
- run: |
    python3 gen.py
    git status --porcelain
    test -z "$(git status --porcelain)"
```

Run the generator with the version the repository pins, in the same job as the build, after dependencies are installed. Printing the status before testing it puts the changed paths in the log, so the author knows what to regenerate.

## When the check fails for another reason

| Failure | Cause | Fix |
| --- | --- | --- |
| Modified or new generated files | The source changed without regeneration | Run the generator and commit |
| Every file differs on every run | A timestamp, absolute path or unordered map in the output | Make the generator deterministic |
| Differs only in CI | Another generator version or platform line endings | Pin the generator; set `.gitattributes` for the output |
| A generated file was edited by hand | Someone patched the output | Move the change into the source or the generator |

The second row is the one to fix first, because a check that always fails is soon skipped. Running the generator twice locally and comparing the outputs shows whether it is deterministic.

A green check from this step covers the generator's output for the files it writes. It does not cover output that a different generator or build step produces, so each generator needs its own step. For who should review generated output in a pull request, see [owners for generated code](/learn/codeowners-generated-and-vendored-files/). For build output restored from another commit, see [a restore key that brought back old output](/learn/actions-cache-restore-keys-stale-output/).

## One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. [Eligibility and fair-use terms](/free-code-review/).

[Start free with GitHub](https://proofline.sh/orgs/plan?offer=free_month)

## Related reading

-   ### [Who should own lockfiles, generated code and vendored directories?](/learn/codeowners-generated-and-vendored-files/)
    
    Code review The Proofline team November 23, 2026 4 min read
    
-   ### [A cache restore key brought back an old build's output](/learn/actions-cache-restore-keys-stale-output/)
    
    Code review The Proofline team December 2, 2026 3 min read
