Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to use gogo/protobuf registered types in gRPC Status errors #576

Closed
johanbrandhorst opened this issue Mar 17, 2018 · 2 comments
Closed

Comments

@johanbrandhorst
Copy link
Collaborator

The gRPC-Gateway uses the gRPC status package for writing rich gRPC errors to the JSON response of a gRPC call. Unfortunately, the use of status.Details() directly assumes all proto message types stored in the status are registered with the golang/protobuf proto type registry. Ideally the gRPC Gateway would simply allow the JSON marshaller to marshal the messages, which would leave such type resolution to the marshaller, and not the runtime.

To be specific, this bug refers to the handling of the status in

for _, detail := range s.Details() {
if det, ok := detail.(proto.Message); ok {
a, err := ptypes.MarshalAny(det)
if err != nil {
grpclog.Printf("Failed to marshal any: %v", err)
} else {
body.Details = append(body.Details, a)
}
}
}

johanbrandhorst added a commit to johanbrandhorst/grpc-gateway that referenced this issue Mar 17, 2018
johanbrandhorst added a commit to johanbrandhorst/grpc-gateway that referenced this issue Mar 17, 2018
johanbrandhorst added a commit to johanbrandhorst/grpc-gateway that referenced this issue Apr 24, 2018
@tmc
Copy link
Collaborator

tmc commented Jun 19, 2018

If this is the only issue from using gogo types we should absolutely get this fixed.

@johanbrandhorst
Copy link
Collaborator Author

Yeah I think this will go some way but it's not the only problem. Please see the grpc-gateway section of my post on gogoproto compatibility: https://jbrandhorst.com/post/gogoproto/. Theres nothing that cant be worked around though.

johanbrandhorst added a commit to johanbrandhorst/grpc-gateway that referenced this issue Jun 19, 2018
johanbrandhorst added a commit to johanbrandhorst/grpc-gateway that referenced this issue Jun 19, 2018
Fixes grpc-ecosystem#576. Adds a test case for marshalling of details as well.
johanbrandhorst added a commit to johanbrandhorst/grpc-gateway that referenced this issue Jun 22, 2018
Fixes grpc-ecosystem#576. Adds a test case for marshalling of details as well.
achew22 pushed a commit that referenced this issue Jun 22, 2018
Fixes #576. Adds a test case for marshalling of details as well.
adasari pushed a commit to adasari/grpc-gateway that referenced this issue Apr 9, 2020
Fixes grpc-ecosystem#576. Adds a test case for marshalling of details as well.
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

No branches or pull requests

2 participants