Skip to content

fix(validator): run buf lint/breaking from module root with --path#6

Merged
daniel-garcia merged 2 commits into
mainfrom
fix-finalize-buf-path
Jun 10, 2026
Merged

fix(validator): run buf lint/breaking from module root with --path#6
daniel-garcia merged 2 commits into
mainfrom
fix-finalize-buf-path

Conversation

@daniel-garcia

Copy link
Copy Markdown
Contributor

What

apx release finalize re-validates the schema with buf lint / buf breaking, invoking buf with
the API subdirectory as a positional build input:

exec.Command(bufPath, "lint", absPath)                              // internal/validator/proto.go
exec.Command(bufPath, "breaking", absPath, "--against", againstArg)

For any canonical repo whose protos live under a buf v2 module (module_roots: [proto]), buf
rejects this:

Failure: failed to build input "proto/<domain>/<name>/v1" because it is contained by module at
path "proto" specified in your configuration, you must provide the workspace or module as the
input, and filter to this path using --path

This makes finalize fail at re-validation for every proto-module repo, so a versioned release
tag can never be cut. (apx lint with no args is unaffected because it lints the whole module.)

Fix

ProtoValidator.Lint/Breaking now resolve the buf workspace/module root (nearest ancestor with
buf.work.yaml/buf.yaml), run buf from that root, and select the target via --path:

buf lint --path proto/<domain>/<name>/v1
buf breaking --against <ref> --path proto/<domain>/<name>/v1

This is the buf-blessed invocation (verified: the equivalent command exits 0 on a real canonical
repo where the old form fails). When the schema dir is itself the module root, --path is omitted.

A bufRootAndPath helper does the root detection; added TestBufRootAndPath (pure filesystem,
no buf needed). go build ./... and go test ./internal/validator/... pass.

Context

This is finding #1 of #5. That issue also tracks three related release-pipeline
gaps (finalize unwired in canonical CI; tag …/v1/vX vs go-module …/<name> mismatch;
apx auth login not persisting a usable token) which are out of scope for this PR.

Closes #5 partially (finding #1).

buf v2 rejects a path contained by a module as a positional build input, so
release finalize's re-validation failed for every proto-module canonical repo.
Resolve the buf workspace/module root and select the target schema dir via
--path instead. Adds bufRootAndPath + TestBufRootAndPath.
buf v2 rejects --path when the path is itself a module root (it must be the
positional input) and rejects a positional input contained by a module (must
use --path). Decide based on the module paths declared in buf.yaml/buf.work.yaml
so both 'apx lint proto' (module root) and finalize's per-API subdir validation
work. Fixes the TestScript lint_proto/breaking_proto regressions.
@daniel-garcia daniel-garcia merged commit 7930441 into main Jun 10, 2026
7 of 8 checks passed
@daniel-garcia daniel-garcia deleted the fix-finalize-buf-path branch June 10, 2026 05:38
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.

release finalize fails on proto-module repos (buf invocation) + 3 related release-pipeline gaps

1 participant