bradleyjkemp/grpc-tools

grpc-dump prints warning if nested message is null (not set)

Opened this issue · 0 comments

Like this:

WARN[0004] Failed to search for unknown fields in message =proto_decoder error="failed to enrich decode descriptor: failed to search nested field foo: internal: got nil message"

Steps to reproduce:

  1. Start greeter_server
$ ~/go/bin/greeter_server
...
  1. Download helloworld.proto to proto/helloworld/helloworld.proto
  2. Edit helloworld.proto and add a nested message to HelloRequest:
message HelloRequest {
  string name = 1;
  Foo foo = 2;
}

message Foo {
    string bar = 1;
}
  1. Start grpc-dump:
$ ~/go/bin/grpc-dump -port 8980 -destination localhost:50051 -proto_roots proto
...
  1. Call SayHello with grpc_cli and omit foo:
$ grpc_cli -remotedb=false -proto_path proto -protofiles helloworld/helloworld.proto \
    call localhost:8980 helloworld.Greeter/SayHello 'name:"world"'
...
  1. grpc-dump prints a warning:
WARN[0004] Failed to search for unknown fields in message  =proto_decoder error="failed to enrich decode descriptor: failed to search nested field foo: internal: got nil message"
{"service":"helloworld.Greeter","method":"SayHello","messages":[{"message_origin":"client","raw_message":"CgV3b3JsZA==","message":{"name":"world"},"timestamp":"2020-03-31T22:37:14.401284+03:00"},{"message_origin":"server","raw_message":"CgtIZWxsbyB3b3JsZA==","message":{"message":"Hello world"},"timestamp":"2020-03-31T22:37:14.402273+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. Now 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. No warning:
{"service":"helloworld.Greeter","method":"SayHello","messages":[{"message_origin":"client","raw_message":"CgV3b3JsZBIA","message":{"name":"world","foo":{}},"timestamp":"2020-03-31T22:38:07.585913+03:00"},{"message_origin":"server","raw_message":"CgtIZWxsbyB3b3JsZA==","message":{"message":"Hello world"},"timestamp":"2020-03-31T22:38:07.586199+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. Repeat steps 3-8 with response.