Skip to content

buf v2 config - #859

Merged
dandavison merged 6 commits into
mainfrom
dan/buf-v2-config
Aug 25, 2026
Merged

buf v2 config#859
dandavison merged 6 commits into
mainfrom
dan/buf-v2-config

Conversation

@dandavison

@dandavison dandavison commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

What changed?

  • Migrated buf.yaml and buf.lock from config v1 to v2 using buf config migrate --module ..

  • Bumped buf pinned in the Makefile from v1.27.0 to v1.49.0, and renamed buf mod prune to buf dep prune.

  • Dropped the unused buf.build/grpc-ecosystem/grpc-gateway dependency.

  • Renamed the lint category DEFAULT to STANDARD, and replaced the two comments on excludes with one line.

  • Deleted buf.gen.yaml

Why?

  • LSP support: The buf language server does not discover module roots from a v1 buf.yaml.

  • pin has to move because v1.27.0 predates v2 and rejects it. v1.49.0 is the version .github/workflows/push-to-buf.yml already runs against this repo.

  • DEFAULT was renamed to STANDARD in buf v1.40.0.

  • AFAIK no-one calls buf generate; we use protoc

Breaking changes

Rerun make buf-install to pick up the new buf. Otherwise none.

Preparation for migrating buf.yaml to v2. The pinned v1.27.0 predates v2
config and rejects it outright, so it has to move first. v1.49.0 is what
.github/workflows/push-to-buf.yml already runs against this repo.

v1.32.0 moved buf mod prune to buf dep prune and deprecated the old spelling,
so the Makefile target follows.

Any buf that new also prunes buf.build/grpc-ecosystem/grpc-gateway out of
buf.lock, because nothing under temporal/ imports it. Left in buf.yaml, that
prune would dirty the tree and fail CI's uncommitted-changes check, so drop the
dep and commit the pruned lock.
Autogenerated, no hand edits:

    buf config migrate --module .

buf's own migration path, per
https://buf.build/docs/migration-guides/migrate-v2-config-files/. --module
restricts it to buf.yaml and buf.lock, leaving buf.gen.yaml at v1; that file is
unreferenced by the Makefile and CI and points at a protoc-gen-go-helpers
directory that does not exist here, so it is dead config and out of scope.

v2 exists since v1.32.0. v1 remains supported with no deadline, so this is not
a forced upgrade; the motivation is that the buf language server does not
discover module roots from a v1 buf.yaml, and reports every import in every
.proto as unresolved.

The added lint and breaking except entries are the tool preserving current
behaviour: v2 turns on rules that v1 did not run.
Two hand fixups on top of the generated migration.

buf config migrate rewrites buf.yaml structurally and drops comments. The two
comments on excludes are replaced by one line stating why they are needed, both
halves of which are verified: dropping either exclude makes buf build fail with
"contained in multiple modules", and moving either vendored directory aside
makes api-linter fail to resolve its imports, since it reads -I paths and not
the BSR.

v1.40.0 renamed the DEFAULT lint category to STANDARD and buf warns on every
invocation while the old name is used. buf config ls-lint-rules on each expands
to the same 36 rules, so this is a rename only. The tool does not do it because
DEFAULT still works.
@dandavison
dandavison marked this pull request as ready for review August 25, 2026 15:23
@dandavison
dandavison requested review from a team, mjameswh, stephanos and tdeebswihart August 25, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates Buf module configuration to v2 and updates the pinned Buf CLI.

Changes:

  • Migrates module, lint, breaking-change, and lockfile configuration to v2.
  • Updates Buf to v1.49.0 and adopts buf dep prune.
  • Removes an unused dependency and the generation template.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
Makefile Updates Buf installation and dependency pruning.
buf.yaml Migrates module configuration to v2.
buf.lock Migrates dependency locks to v2.
buf.gen.yaml Deletes the Buf generation template.
Suppressed comments (1)

buf.gen.yaml:1

  • Deleting the repository’s generation template removes the configuration discovered by buf generate; that command will now fail unless every caller supplies an external template. Preserve this file (migrating it to v2 if desired), or add an equivalent replacement rather than removing generation support as part of the module-config migration.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread buf.yaml
- google
- nexusannotations
deps:
- buf.build/grpc-ecosystem/grpc-gateway

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we never used this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

Comment thread buf.yaml Outdated
Comment on lines +16 to +17
- FIELD_NOT_REQUIRED
- PACKAGE_NO_IMPORT_CYCLE

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these precautionary exclusions or would these actually break the lint today?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. They were added automatically by buf config migrate --module . in d81350b, but I've removed them now.

@dandavison
dandavison requested a review from stephanos August 25, 2026 16:28

@stephanos stephanos left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with limited buf knowledge. Fact that behavior seems the same is good.

Comment thread buf.yaml Outdated
- DEFAULT
- WIRE_JSON
except:
- FIELD_SAME_DEFAULT

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also check if this is needed.

@mjameswh

Copy link
Copy Markdown
Contributor

I’m missing context, and don’t know much about buf either, so I might be missing something.

But it indeed looks like we’re only using buf for checking/manipulating the proto files internally to the repo itself (lint/prune/breaking checks), not to generate anything “important” or that would be consumed by other repos — we use protoc for that. So removing the buf.gen.yaml seems safe.

As for the version bump and config change, the worst case would be developer frictions (our devs, not external) if the new version/config results in different stylistic/linting recommendations. I assume you did exercise all the make commands and CI jobs that use buf, and confirmed nothing new comes up?

So LGTM.

@dandavison
dandavison merged commit 56f6aa1 into main Aug 25, 2026
4 checks passed
@dandavison
dandavison deleted the dan/buf-v2-config branch August 25, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants