fullstorydev / grpcurl

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

Service reflection is failing if proto file imports another proto from different project. #349

Closed voroninp closed 1 year ago

voroninp commented 1 year ago

I use GRPCurl service discovery, and I get the following error:

Failed to resolve symbol "radio_data.RadioDataService": Symbol not found: radio_data.RadioDataService caused by: File not found: CalculationEngine.Shared.Grpc/Protos/data.proto

The reason is that my radio_data file imports another proto:

import "CalculationEngine.Shared.Grpc/Protos/data.proto";

And csproj file entry is the following:

<ItemGroup>
  <Protobuf Include="..\$(MSBuildProjectName)\Protos\radio_data.proto" ProtoRoot=".." GrpcServices="Server,Client" />
</ItemGroup>

Here's generated DataReflection class for data.proto:

public static partial class DataReflection {

  #region Descriptor
  /// <summary>File descriptor for Protos/data.proto</summary>
  public static pbr::FileDescriptor Descriptor {
    get { return descriptor; }
  }
  private static pbr::FileDescriptor descriptor;

  static DataReflection() {
    byte[] descriptorData = global::System.Convert.FromBase64String(
        string.Concat(
          "ChFQcm90b3MvZGF0YS5wcm90bxIEZGF0YSIcCglCeXRlQ2h1bmsSDwoHQ29u",
          "dGVudBgBIAEoDCIwCgREYXRlEgwKBFllYXIYASABKAUSDQoFTW9udGgYAiAB",
          "KAUSCwoDRGF5GAMgASgFQiCqAh1DYWxjdWxhdGlvbkVuZ2luZS5TaGFyZWQu",
          "R3JwY2IGcHJvdG8z"));
    descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
        new pbr::FileDescriptor[] { },
        new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
          new pbr::GeneratedClrTypeInfo(typeof(global::CalculationEngine.Shared.Grpc.ByteChunk), global::CalculationEngine.Shared.Grpc.ByteChunk.Parser, new[]{ "Content" }, null, null, null, null),
          new pbr::GeneratedClrTypeInfo(typeof(global::CalculationEngine.Shared.Grpc.Date), global::CalculationEngine.Shared.Grpc.Date.Parser, new[]{ "Year", "Month", "Day" }, null, null, null, null)
        }));
  }
  #endregion
}
jhump commented 1 year ago

@voroninp, if the full set of transitive dependencies for your service is not available for download from the C# server reflection implementation, I think you are possibly using it incorrectly or the C# implementation has a bug.

There is no possible fix in the client for this: if it cannot get the necessary descriptors from the server, it cannot construct the internal model it needs for doing dynamic RPC.

sanjaybv commented 1 year ago

@voroninp Looks like you figured out the issue. Please let us know if there is something else.