Skip to content

Add RpcStatus, Wire's google.rpc.Status - #3758

Open
oldergod wants to merge 2 commits into
masterfrom
bquenaudon/rpc-status
Open

oldergod wants to merge 2 commits into
masterfrom
bquenaudon/rpc-status

Conversation

@oldergod

@oldergod oldergod commented Nov 9, 2026

Copy link
Copy Markdown
Member

Wire has AnyMessage for google.protobuf.Any, but nothing for google.rpc.Status. Users must generate status.proto from googleapis. That class is com.google.rpc.Status, which conflicts with the class from proto-google-common-protos when grpc-java is also on the classpath. Misk works around this with its own misk.proto.Status, which has a different type URL.

Status needs no special encoding: it is a plain message. This PR adds a shared runtime type for it, and uses that type in gRPC errors.

  • wire-runtime: add RpcStatus. It is Wire's Kotlin output for google/rpc/status.proto, renamed. Its type URL stays type.googleapis.com/google.rpc.Status.
  • wire-schema: bundle google/rpc/status.proto and add ProtoType.RPC_STATUS. A status.proto on the user's proto path still takes precedence.
  • Kotlin and Java generators: map google.rpc.Status to RpcStatus, as google.protobuf.Any maps to AnyMessage. Wire never generates its own copy.
  • wire-grpc-client: GrpcException.rpcStatus decodes the grpc-status-details-bin trailer. A new constructor creates the exception from an RpcStatus.

Open questions:

  • Name and module. RpcStatus in wire-runtime lets any generated code use it without a gRPC dependency. The other choice is wire-grpc-client.
  • Compatibility. Users who generate status.proto themselves will now get RpcStatus fields instead of com.google.rpc.Status. The Proto target also stops emitting google/rpc/status.proto.
  • Swift is not changed. Swift still generates google.rpc.Status as a normal message.
  • google/rpc/error_details.proto (ErrorInfo, RetryInfo, BadRequest) could follow in a later PR.

Wire now bundles google/rpc/status.proto and maps google.rpc.Status to
com.squareup.wire.RpcStatus in Kotlin and Java, like it maps
google.protobuf.Any to AnyMessage. Generated code no longer needs a
googleapis dependency or its own copy, and it can't conflict with
com.google.rpc.Status from proto-google-common-protos.

GrpcException exposes the grpc-status-details-bin trailer as a decoded
RpcStatus, and can be created from one.
Wire now maps google.rpc.Status to RpcStatus and never generates it.

@escardin escardin 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.

Thanks for doing this, it looks great

@oldergod
oldergod marked this pull request as ready for review November 10, 2026 14:47

This branch has not been deployed

No deployments
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