Skip to content

fix(connect): register v1 service paths for buf v2 config#28

Merged
onokonem merged 3 commits into
mainfrom
fix/buf-proto-update
May 29, 2026
Merged

fix(connect): register v1 service paths for buf v2 config#28
onokonem merged 3 commits into
mainfrom
fix/buf-proto-update

Conversation

@onokonem
Copy link
Copy Markdown
Contributor

Summary

Fix: buf v2 config content-type mismatch

When buf dep update is run with a v2 buf.yaml config against the proxy, the buf CLI calls v1 API paths (buf.registry.module.v1.CommitService/GetCommits). Only v1beta1 routes were registered for CommitService, GraphService, and DownloadService — the v1 paths fell through to rootHandler, which returns 200 OK with Content-Type: text/plain; charset=utf-8.

This caused the error:

Failure: unknown: invalid content-type: "text/plain; charset=utf-8"; expecting "application/proto"

Changes

Add v1 route registrations

Register v1 service paths alongside existing v1beta1 paths for CommitService, GraphService, and DownloadService in internal/connect/api.go, matching the pattern already used by ModuleService.

Key files:

  • internal/connect/api.go — added 3 v1 route registrations

Add comprehensive route tests

New test file internal/connect/api_test.go with 6 test functions covering:

  • All 8 service paths (4 services × v1/v1beta1) don't fall through to rootHandler
  • CommitService, GraphService, DownloadService return application/proto with valid protobuf on both v1 and v1beta1 paths
  • GET requests return 405 Method Not Allowed

Key files:

  • internal/connect/api_test.go — new test file (424 lines)

Verification

  • All unit tests pass (go test ./internal/connect/ — 28 subtests, 0 failures)
  • v1 paths return application/proto (not text/plain)
  • v1beta1 paths still work (regression check)

🤖 Generated with Claude Code

onokonem and others added 2 commits May 29, 2026 23:29
CommitService, GraphService, and DownloadService only had v1beta1 routes
registered. Buf CLI with v2 buf.yaml config calls v1 API paths, which fell
through to rootHandler returning text/plain — causing "invalid content-type"
errors.

Add v1 route registrations alongside v1beta1 for all three services,
matching the pattern already used by ModuleService.

Adds comprehensive tests verifying v1 and v1beta1 paths return
application/proto content-type and valid protobuf responses.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@onokonem onokonem self-assigned this May 29, 2026
- test.yml: run unit tests on PR and push to main
- security.yml: weekly govulncheck + dependency review

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@onokonem onokonem merged commit 8cf1da5 into main May 29, 2026
1 check passed
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.

2 participants