Unable to access trailers/headers of a failed gRPC call
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
Issue Description:
When using wire for gRPC communication, I encountered an issue where I cannot access the trailers or headers of a gRPC call after it fails and throws a GrpcException. The exception itself provides valuable information about the failure, but I need to access additional details present in the trailers or headers for better error handling and logging purposes.
Steps to Reproduce:
- Use Square's Wire library to make a gRPC call.
- Wait for the call to fail and throw a
GrpcException. - Attempt to access the trailers or headers associated with the failed call.
Expected Behavior:
After a gRPC call fails and throws a GrpcException, I should be able to access the trailers or headers of the failed call to retrieve additional information about the failure.
Actual Behavior:
Currently, when a gRPC call fails and throws a GrpcException, I have been unable to find a way to access the trailers or headers associated with the failed call. The exception itself provides useful details, but it would be beneficial to have access to the trailers or headers for more comprehensive error handling and logging.
Additional Information:
- I am using Square's Wire library version 4.5.6.
- I have reviewed the library's documentation, but couldn't find any specific information or examples regarding accessing trailers or headers after a failed gRPC call.
- I have searched through the library's source code, but couldn't identify any methods or properties that expose the trailers or headers in the context of a
GrpcException.
Possible Solution:
One possible solution to this issue could be to provide a way to access the trailers or headers associated with a gRPC call after it fails and throws a GrpcException. This could be achieved by exposing a method or property in the exception class that allows retrieving the trailers or headers. Something like this:
class GrpcException(
val grpcStatus: GrpcStatus,
val grpcMessage: String?,
val trailers: GrpcHeaders,
val headers: GrpcHeaders,
val grpcStatusDetails: ByteArray? = null,
) : IOException("grpc-status=${grpcStatus.code}, grpc-status-name=${grpcStatus.name}, grpc-message=$grpcMessage")
and then, when converting GrpcResponse to a GrpcException using GrpcResponse.grpcResponseToException, it set headers and trailers too.
Alternatively, if there is already a way to access the trailers or headers I may have missed, please guide how to do so.
Thank you for your attention to this matter. Please let me know if further information is required to address this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading GrpcException and GrpcResponse.grpcResponseToException, then trace how a failed gRPC call is converted into the exception. Check the existing documentation and source for how headers and trailers are represented. Done means callers can retrieve the failed call's headers and trailers through the exception, with behavior covered by the relevant tests if present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100