grpc / grpc-java

The Java gRPC implementation. HTTP/2 based RPC
https://grpc.io/docs/languages/java/
Apache License 2.0
11.48k stars 3.85k forks source link

Support for details in status payloads #11616

Closed friscoMad closed 1 month ago

friscoMad commented 1 month ago

I have not been able to find out a way to recover the details included in a server response status message, it seems that they are not included in grpc.io Status class and thus are not accessible from the StatusException thrown on server errors. Is there a way to recover and access the details field from the client or using the details field is discouraged. We were planning on using the recommended payload list from here: https://cloud.google.com/apis/design/errors#error_payloads but if the information can not be retrieved from the client it does not make sense to send.

For context we are using grpc-java 1.66 + grpc-kotlin 1.4.1 but the models are in the grpc-java side.

kannanjgithub commented 1 month ago

There is a description field in Status and this is what is set by the gRPC server to add error details (example). Is your client not seeing this field set?

ejona86 commented 1 month ago

I think @kannanjgithub intended to link to this example: https://github.com/grpc/grpc-java/blob/99f86835ed8a1c960d532e58b5fd51ec1bb99825/examples/src/main/java/io/grpc/examples/errordetails/ErrorDetailsExample.java#L125

See also the gRPC guide that covers discusses the cross-language concepts.

friscoMad commented 1 month ago

As I understand over the wire what it is sent is this model that include the details field with extra information about the error cause. I was hoping to have access to that information from the client side, as far as I can tell that detail field is not included in the description as expected but is not stored in the io.grpc.Status object.

But after some more exploring it seems that details should be present in the metadata part of the exception and they were not there due to an unrelated bug.