Skip to content

errors: migrate from gogo/protobuf to google.golang.org/protobuf#165

Open
liran-funaro wants to merge 1 commit into
cockroachdb:masterfrom
liran-funaro:remove-gogo
Open

errors: migrate from gogo/protobuf to google.golang.org/protobuf#165
liran-funaro wants to merge 1 commit into
cockroachdb:masterfrom
liran-funaro:remove-gogo

Conversation

@liran-funaro

@liran-funaro liran-funaro commented Jul 12, 2026

Copy link
Copy Markdown

github.com/gogo/protobuf, along with the related github.com/gogo/status and github.com/gogo/googleapis, is deprecated and unmaintained. This migrates the whole module to the standard, maintained protobuf stack it already depended on: google.golang.org/protobuf (+ anypb), google.golang.org/grpc/status, and
google.golang.org/genproto/googleapis/rpc/status.

The .proto files are regenerated with the standard protoc-gen-go and protoc-gen-go-grpc, dropping the custom protoc-gen-gogoroach plugin and all gogoproto options, and the hand-written code is adapted to the v2 runtime:

  • errbase packs and unpacks error detail payloads with anypb.New and (*anypb.Any).UnmarshalNew, resolving types through the standard protoregistry instead of gogo's registry.
  • The previously non-nullable embedded fields (Details, Cause, ErrorTypeMark) are now pointers, read through the generated nil-safe getters. DecodeError takes *EncodedError and GetTypeMark returns *errorspb.ErrorTypeMark accordingly.
  • extgrpc and grpc/middleware use google.golang.org/grpc/status. Because the standard Any can hold standard protobufs directly, the former gogo/standard status split collapses into a single path, and google.rpc.Status now comes from genproto with the same type URL.
  • go.mod drops all three gogo modules.

Wire compatibility is preserved: no proto package/message name or field number changes, and google.protobuf.Any type URLs are unchanged, so errors serialized by the previous gogo-based version still decode here and vice versa.

This is a breaking API change (major version): the encoder/decoder registration interfaces now reference the v2 proto.Message, so consumers that register custom error types must supply standard-protobuf payloads. Errors originally produced as github.com/gogo/status types decode to an opaque error (message and safe details preserved) rather than being reconstructed as a gRPC status.

@cockroachlabs-cla-agent

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

github.com/gogo/protobuf, along with the related github.com/gogo/status
and github.com/gogo/googleapis, is deprecated and unmaintained. This
migrates the whole module to the standard, maintained protobuf stack it
already depended on: google.golang.org/protobuf (+ anypb),
google.golang.org/grpc/status, and
google.golang.org/genproto/googleapis/rpc/status.

The .proto files are regenerated with the standard protoc-gen-go and
protoc-gen-go-grpc, dropping the custom protoc-gen-gogoroach plugin and
all gogoproto options, and the hand-written code is adapted to the v2
runtime:

- errbase packs and unpacks error detail payloads with anypb.New and
  (*anypb.Any).UnmarshalNew, resolving types through the standard
  protoregistry instead of gogo's registry.
- The previously non-nullable embedded fields (Details, Cause,
  ErrorTypeMark) are now pointers, read through the generated nil-safe
  getters. DecodeError takes *EncodedError and GetTypeMark returns
  *errorspb.ErrorTypeMark accordingly.
- extgrpc and grpc/middleware use google.golang.org/grpc/status. Because
  the standard Any can hold standard protobufs directly, the former
  gogo/standard status split collapses into a single path, and
  google.rpc.Status now comes from genproto with the same type URL.
- go.mod drops all three gogo modules.

Wire compatibility is preserved: no proto package/message name or field
number changes, and google.protobuf.Any type URLs are unchanged, so
errors serialized by the previous gogo-based version still decode here
and vice versa.

This is a breaking API change (major version): the encoder/decoder
registration interfaces now reference the v2 proto.Message, so consumers
that register custom error types must supply standard-protobuf payloads.
Errors originally produced as github.com/gogo/status types decode to an
opaque error (message and safe details preserved) rather than being
reconstructed as a gRPC status.

Signed-off-by: Liran Funaro <liran.funaro@gmail.com>
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.

Gogoprotobuf replacement

1 participant