fullstorydev / grpcurl

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

describe enum - Failed to resolve symbol #228

Open MuForum opened 3 years ago

MuForum commented 3 years ago

Hi. I'm trying to get the description of an enum and it gives me an error: "Failed to resolve symbol "com.nms.noc.fm.grpc.AlarmState": Symbol not found: com.nms.noc.fm.grpc.AlarmState"

syntax = "proto3";

import "google/protobuf/empty.proto";
package com.nms.noc.fm.grpc;

option java_package = "com.nms.noc.fm.grpc";

option java_multiple_files = true;
option java_outer_classname = "FMGrpcService";

service FMService {
    rpc setAlarmState(AlarmStateMessage) returns (google.protobuf.Empty);
}

enum AlarmState {
    OPEN = 0;
    ACKNOWLEDGED = 1;
    CLEARED = 2;
}

message AlarmStateMessage {
    int64 alarm_id = 1;
    int32 entity_version = 2;
    AlarmState state = 3;
    string note = 4;
}
$ grpcurl -plaintext 192.168.49.2:31131 describe .com.nms.noc.fm.grpc.FMService
com.nms.noc.fm.grpc.FMService is a service:
service FMService {
  rpc setAlarmState ( .com.nms.noc.fm.grpc.AlarmStateMessage ) returns ( .google.protobuf.Empty );
}

$ grpcurl -plaintext 192.168.49.2:31131 describe .com.nms.noc.fm.grpc.AlarmStateMessage
com.nms.noc.fm.grpc.AlarmStateMessage is a message:
message AlarmStateMessage {
  int64 alarm_id = 1;
  int32 entity_version = 2;
  .com.nms.noc.fm.grpc.AlarmState state = 3;
  string note = 4;
}

$ grpcurl -plaintext 192.168.49.2:31131 describe .com.nms.noc.fm.grpc.AlarmState
Failed to resolve symbol "com.nms.noc.fm.grpc.AlarmState": Symbol not found: com.nms.noc.fm.grpc.AlarmState

P.S. -> How can I get the description of just an enum via the command line?

jhump commented 3 years ago

What language is the server written in?

This appears to be a bug in the server reflection implementation that fails to return the descriptor for this enum.

MuForum commented 3 years ago

Hi @jhump. Java application.

$ java --version
openjdk 11.0.10 2021-01-19 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9-LTS, mixed mode, sharing)
        <!-- GRPC -->
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
            <version>1.34.1</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
            <version>1.34.1</version>
        </dependency>
        <dependency>
            <groupId>net.devh</groupId>
            <artifactId>grpc-spring-boot-starter</artifactId>
            <version>2.10.1.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <!-- https://github.com/xolstice/protobuf-maven-plugin -->
                <version>0.6.1</version>
                <configuration>
                    <!-- https://github.com/protocolbuffers/protobuf -->
                    <protocArtifact>com.google.protobuf:protoc:3.15.8:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <!-- https://github.com/grpc/grpc-java -->
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.37.0:exe:${os.detected.classifier}</pluginArtifact>
                    <includes>
                        <include>**/FM_FMService.proto</include>
                    </includes>
                    <protoSourceRoot>${project.basedir}/Interfaces/Proto/1.0</protoSourceRoot>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
jhump commented 3 years ago

@MuForum, this is an issue in the grpc-java implementation: https://github.com/grpc/grpc-java/blob/72527708f552036ffcd70923ff12a4b26c9d17d4/services/src/main/java/io/grpc/protobuf/services/ProtoReflectionService.java#L486 It is not adding enums to the set of indexed descriptor names. That means that it cannot answer reflection calls that ask to fetch descriptors via an enum name, which is what happens when you try to describe an enum.