fullstorydev / grpcurl

Like cURL, but for gRPC: Command-line tool for interacting with gRPC servers
MIT License
10.35k stars 497 forks source link

protoset-out does not get namespace when using reflection #464

Closed NGuldager closed 1 month ago

NGuldager commented 1 month ago

Using -protoset-out to generate descriptors does not seem to keep namespaces for types when using reflection.

When comparing the descriptors using protoc --decode_raw for the same service using either the .proto file or reflection the field looks as follows

From reflection From .proto file
``` 1: "Identifier" 2 { 1: "type" 3: 1 4: 1 5: 14 6: "IdentifierType" } } ``` ``` 1: "Identifier" 2 { 1: "type" 3: 1 4: 1 5: 14 6: ".reporting.consumption.IdentifierType" 10: "type" } ```

Using reflection on the same server using https://github.com/fullstorydev/grpcui it sees that the namespace is definitely available for reflection:

image

Generating grpc clients fails if the namespace is not available, for a lot of reasons using the .proto file directly is not easily achievable, so getting the full type to the descriptors is highly preferable

jhump commented 1 month ago

What server implementation is returning that from the reflection endpoint? This seems like a clear bug in the reflection endpoint. If the type references are not qualified, they are not valid.

NGuldager commented 1 month ago

What server implementation is returning that from the reflection endpoint? This seems like a clear bug in the reflection endpoint. If the type references are not qualified, they are not valid.

We're using nestjs. But the grpcui is getting the correct namespace on the same server using reflection only. So I don't think it's in the server. But I might be wrong

jhump commented 1 month ago

But the grpcui is getting the correct namespace on the same server using reflection only.

This seems rather hard to understand since grpcui uses grpcurl as a library, and uses the exact same code to load/process the schemas.

What version of grpcurl and what version of grpcui?

NGuldager commented 1 month ago

After spending most of my day yesterday debugging and diving down into the code of various libraries. The issues seems to be with how protobufjs generates the binaries vs how protoc does.

From my understanding of grpcurl and grpcui, and please correct me if I'm wrong:

When using -protoset-out in grpcurl it just saves the descriptor exactly like the server reflection returns. While grpcui uses GetFullyQualifiedName from protoreflect that does more than just show the type directly from the binary. Which also happens in grpcui, but only for the displayed values in the terminal, and not for the binary.

NGuldager commented 1 month ago

The issues seems to be with how protobufjs generates the binaries vs how protoc does.

Closing because I don't think this is caused by grpcurl