grpc / grpc-kotlin

Kotlin gRPC implementation. HTTP/2 based RPC
https://grpc.io/docs/languages/kotlin
Apache License 2.0
1.2k stars 166 forks source link

"ErrorInfo" message type and the corresponding Java class cannot be used. #222

Open nyandora opened 3 years ago

nyandora commented 3 years ago

Issue

In this guide by Google, pre-defined message types be able to used for error-handling are introduced. Specifically, these message types are defined in google/rpc/error_details.proto. For example, BadRequest message type and Java class can be used for handling validation errors.

In the guide above, ErrorInfo message type is also introduced. But I cannot use this message type and Java class in this repository.

Reason I assume

Investigating the reason, I found that these message types and Java classes are included in the artifact com.google.api.grpc:proto-google-common-protos:1.17.0 depended by io.grpc:grpc-protobuf:1.29.0 as following.

\--- io.grpc:grpc-kotlin-stub:1.0.0
     +--- io.grpc:grpc-protobuf:1.29.0
     |    +--- com.google.api.grpc:proto-google-common-protos:1.17.0

In com.google.api.grpc:proto-google-common-protos:1.17.0 above, I can find BadRequest message type but cannot find ErrorInfo message type.

I assume this version of proto-google-common-protos is old.

My Request

I would like to use "ErrorInfo" message type and Java class. Could you update io.grpc:grpc-protobuf version for updating com.google.api.grpc:proto-google-common-protos ?

jamesward commented 3 years ago

You should be able to workaround this by overriding the transitive dependency. Let me know if that works.

I think we can also bump our io.grpc:grpc-protobuf transitive to the latest (currently 1.35.0) which depends on proto-google-common-protos 2.0.1.

nyandora commented 3 years ago

@jamesward Thanks for your reply. I tried your proposal. The result is below.

override proto-google-common-protos version.

    implementation("com.google.api.grpc:proto-google-common-protos") {
        version {
            strictly("2.0.1")
        }
    }

It's fine.

override io.grpc:grpc-protobuf version.

    implementation("io.grpc:grpc-protobuf") {
        version {
            strictly("1.35.0")
        }
    }

As a result, grpc client got an error below.

 io.grpc.internal.ManagedChannelImpl$2 uncaughtException
 [Channel<1>: (localhost:50051)] Uncaught exception in the SynchronizationContext. Panic!
java.lang.NoSuchFieldError: ATTR_LOAD_BALANCING_CONFIG
        at io.grpc.internal.AutoConfiguredLoadBalancerFactory$AutoConfiguredLoadBalancer.tryHandleResolvedAddresses(AutoConfiguredLoadBalancerFactory.java:114)
        at io.grpc.internal.ManagedChannelImpl$NameResolverListener$1NamesResolved.run(ManagedChannelImpl.java:1601)
        at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:95)
        at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:127)
        at io.grpc.internal.ManagedChannelImpl$NameResolverListener.onResult(ManagedChannelImpl.java:1615)
        at io.grpc.internal.DnsNameResolver$Resolve.run(DnsNameResolver.java:333)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
jamesward commented 3 years ago

Looks like there is an incompatibility with upgrading io.grpc:grpc-protobuf but do you need that one upgraded or just the protos?

nyandora commented 3 years ago

I could not decide it. I would like to use ErrorInfo without any incompatibility problems. What is the best way ?