elixir-grpc / grpc-reflection

elixir graph reflection support
Apache License 2.0
9 stars 6 forks source link

[bugfix] uniq for dependencies #13

Closed zhihuizhang17 closed 10 months ago

zhihuizhang17 commented 10 months ago

Summary

This fixes grpcurl failures when describing messages with multiple fields of the same type.

Detail

Types reused multiple times in another message were resulting in redundant dependencies in the file descriptors. This caused grpcurl describe calls to fail with:

proto: already imported "google.protobuf.StringValue.proto"

This PR fixes this by deduplicating dependencies per file descriptor.

Unit test

Added test cases with a HelloReply message containing multiple google.protobuf.StringValue fields.

// The response message containing the greetings
message HelloReply {
  string message = 1;
  google.protobuf.Timestamp today = 2;

  google.protobuf.StringValue ext_1 = 3;
  google.protobuf.StringValue ext_2 = 4;
}

Before fix:

> grpcurl -plaintext localhost:50051 describe .helloworld.HelloReply  

Failed to resolve symbol "helloworld.HelloReply": proto: already imported "google.protobuf.StringValue.proto"

After fix:

> grpcurl -plaintext localhost:50051 describe .helloworld.HelloReply                              

helloworld.HelloReply is a message:
message HelloReply {
  string message = 1;
  .google.protobuf.Timestamp today = 2;
  .google.protobuf.StringValue ext_1 = 3;
  .google.protobuf.StringValue ext_2 = 4;
}