Skip to content
Latchkey

CI "uncommitted changes after buf generate" check failure in CI

A protobuf CI gate runs buf generate and then checks for a clean working tree (git diff --exit-code or git status --porcelain). Any change means the committed generated code does not match the current protos, so the job fails until you regenerate and commit.

What this error means

The job reports "uncommitted changes after buf generate" (or a porcelain status listing the generated files) and exits non-zero.

buf
+ buf generate
+ git diff --exit-code
diff --git a/gen/go/api/v1/service.pb.go b/gen/go/api/v1/service.pb.go
@@
Error: uncommitted changes after buf generate

Common causes

Protos changed without regenerating stubs

A .proto edit landed but buf generate was not re-run, so the committed generated stubs are stale.

Plugin versions differ between local and CI

Different local plugin versions than the ones CI uses produce different generated output, creating a diff even without a proto change.

How to fix it

Regenerate with buf and commit

  1. Run buf generate with the configured plugins.
  2. Commit the regenerated files.
  3. Push so the clean-tree check passes.
Terminal
buf generate
git add -A
git commit -m "Regenerate protobuf stubs"

Use remote plugins for reproducible output

Pin remote plugins in buf.gen.yaml so CI and local generate identical code regardless of local installs.

buf.gen.yaml
# buf.gen.yaml
version: v1
plugins:
  - plugin: buf.build/protocolbuffers/go:v1.34.2
    out: gen/go
    opt: paths=source_relative

How to prevent it

  • Pin buf plugin versions (or use versioned remote plugins).
  • Run buf generate before committing proto changes.
  • Gate every PR with a buf generate plus clean-tree check.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →