bradleyjkemp/grpc-tools

grpc-dump outputs nothing if message contains google.protobuf.Any

shinderuk opened this issue · 0 comments

Steps to reproduce:

  1. Start greeter_server
$ ~/go/bin/greeter_server
...
  1. Copy helloworld.proto to proto/helloworld/helloworld.proto
    Copy any.proto to proto/google/protobuf/any.proto
  2. Edit helloworld.proto and add a filed of type Any to request:
import "google/protobuf/any.proto";
...
message HelloRequest {
  string name = 1;
  google.protobuf.Any foo = 2;
}
  1. Start grpc-dump:
$ ~/go/bin/grpc-dump -port 8980 -destination localhost:50051 -proto_roots proto
...
  1. Call SayHello with grpc_cli and pass an empty foo:
$ grpc_cli -remotedb=false -proto_path proto -protofiles helloworld/helloworld.proto \
    call localhost:8980 helloworld.Greeter/SayHello 'name:"world" foo{}'
...
  1. grpc-dump prints a blank line instead of normal output.
  2. Now try again without foo:
$ grpc_cli -remotedb=false -proto_path proto -protofiles helloworld/helloworld.proto \
    call localhost:8980 helloworld.Greeter/SayHello 'name:"world"'
  1. grpc-dump records request/response as expected:
{"service":"helloworld.Greeter","method":"SayHello","messages":[{"message_origin":"client","raw_message":"CgV3b3JsZA==","message":{"name":"world"},"timestamp":"2020-03-31T23:43:03.923154+03:00"},{"message_origin":"server","raw_message":"CgtIZWxsbyB3b3JsZA==","message":{"message":"Hello world"},"timestamp":"2020-03-31T23:43:03.923359+03:00"}],"metadata":{":authority":["localhost:8980"],"accept-encoding":["identity,gzip"],"content-type":["application/grpc"],"grpc-accept-encoding":["identity,deflate,gzip"],"user-agent":["grpc-c++/1.19.1 grpc-c/7.0.0 (osx; chttp2; gold)"],"via":["HTTP/2.0 127.0.0.1:8980"]},"metadata_response_headers":{"content-type":["application/grpc"]},"metadata_response_trailers":{}}
  1. Try adding Any field to response.

Workaround

In proto-files for grpc-dump replace standard Any with MyAny of the same structure.