Skip to content
Latchkey

buf "buf build" Failure compile error in CI

buf build compiles every proto in the module into an image. A compile Failure names the file, line, and column of a syntax error or an import that buf could not resolve from the module roots and dependencies.

What this error means

buf build fails with "Failure:" followed by a file:line:col message such as a missing semicolon, an unknown type, or an import that could not be resolved.

buf build
api/v1/user.proto:9:3:field name "email" is already in use by field "1"
Failure: compile error

Common causes

A syntax or semantic error in a proto

A duplicate field number, unknown type, or missing token stops compilation at the location buf reports.

An import buf cannot resolve

A referenced file is neither in the module nor in a declared dependency, so buf cannot build the image.

How to fix it

Fix the reported location

  1. Open the file at the reported line and column.
  2. Correct the syntax or resolve the duplicate/unknown symbol.
  3. Re-run buf build until it succeeds.

Declare the dependency in buf.yaml

If the error is an unresolved import, add the module that provides it to buf.yaml deps and run buf dep update.

buf.yaml
version: v2
deps:
  - buf.build/googleapis/googleapis

How to prevent it

  • Run buf build locally before pushing to catch compile errors early.
  • Declare every external import as a buf.yaml dependency.
  • Keep buf.lock committed so dependency versions are pinned.

Frequently asked questions

What causes ""Failure: compile error""?
A duplicate field number, unknown type, or missing token stops compilation at the location buf reports.
How do I fix "Failure: compile error"?
Fix the reported location

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card