-
-
Notifications
You must be signed in to change notification settings - Fork 193
Description
Describe the bug
When a gRPC server returns error with own custom messages in status details, evans doesn't display some messages even with --enrich option.
If the message type is defined in dependent proto files from RPC definitions, is it shown. Message types which cannot reach from RPC definitions are not shown.
It happens only when using reflection.
I've confirmed the dangling message is provided as details using another tool https://github.com/fullstorydev/grpcurl.
To reproduce
Here is a Dockerfile to reproduce it: https://github.com/terashi58/grpc-details-test/tree/v0.0.3
$ git clone --branch v0.0.3 https://github.com/terashi58/grpc-details-test.git
$ cd grpc-details-test
$ Docker build . -t grpc-details-test
$ docker run --rm -it grpc-details-test
docker:# tmux
docker:tmux0:# ./bin/server
2022/05/08 07:42:58 server listening at [::]:50051
[Ctrl-b c]
docker:tmux1:# make evans-reflect
echo '{"name":"gopher","error_message":"fail"}' | evans -r cli call --enrich Say
content-type: application/grpc
code: Internal
number: 13
message: "error with details"
details:
{"@type": "type.googleapis.com/sample.Extension", "message": "fail", "subData": {"extended": "sub"}}
{"@type": "type.googleapis.com/google.protobuf.Timestamp", "value": "2022-05-08T07:43:42.103828426Z"}
evans: code = Internal, number = 13, message = "error with details"
make: *** [Makefile:13: evans-reflect] Error 1
Summary of the sample codes:
Here is the gRPC definition:
syntax = 'proto3';
package sample;
import "proto/sub.proto";
option go_package = "github.com/terashi58/grpc-details-test/proto;proto";
service Hello {
rpc Say(SayRequest) returns (SayResponse) {}
}
message Extension {
string message = 1;
SubData sub_data = 2;
}
message SayRequest {
string name = 1;
string error_message = 2;
}
message SayResponse {
string greet = 1;
}And another independent proto file for common error code:
syntax = 'proto3';
package sample;
option go_package = "github.com/terashi58/grpc-details-test/proto;proto";
message ErrorCode {
string value = 1;
}And the RPC implementation:
func (s *server) Say(ctx context.Context, in *pb.SayRequest) (*pb.SayResponse, error) {
log.Printf("Received: %v", in.GetName())
if msg := in.GetErrorMessage(); msg != "" {
st := status.New(codes.Internal, "error with details")
st2, err := st.WithDetails(
&pb.Extension{Message: msg, SubData: &pb.SubData{Extended: "sub"}},
&pb.ErrorCode{Value: "XXX-123"},
ptypes.TimestampNow(),
)
if err != nil {
return nil, err
}
return nil, st2.Err()
}
return &pb.SayResponse{Greet: "Hello " + in.GetName()}, nil
}The rpc returns error with the custom sample.Extension, sample.ErrorCode and google.protobuf.Timestamp as status details.
evans shows the sample.Extension and Timestamp only in the details section.
Expected behavior
The non-dependent message is also shown in the details section:
# echo '{"name":"gopher","error_message":"fail"}' | evans -r cli call --enrich Say
content-type: application/grpc
code: Internal
number: 13
message: "error with details"
details:
{"@type": "type.googleapis.com/sample.Extension", "message": "fail", "subData": {"extended": "sub"}}
{"@type": "type.googleapis.com/sample.ErrorCode", "value": "XXX-123"}
{"@type": "type.googleapis.com/google.protobuf.Timestamp", "value": "2022-05-08T07:49:44.516657185Z"}
evans: code = Internal, number = 13, message = "error with details"
Environment
- OS: Ubuntu 20.04 + debian:bullseye docker image
- Terminal: iTerm2 + tmux (in docker)
- Evans version: master branch (823938c)
protocversion: 3.20.0protocplugin version (if you are using):- protoc-gen-go: 1.28.0
- protoc-gen-go-grpc: 1.2.0
Additional context
You can run the sample server in the docker image by docker run -p 50051:50051 --rm grpc-details-test ./bin/server and test from a local evans.
This is an additional bug report branched from #529.