Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to access trailers/headers of a failed gRPC call #2445

Open
aminmsvi opened this issue Apr 30, 2023 · 0 comments
Open

Unable to access trailers/headers of a failed gRPC call #2445

aminmsvi opened this issue Apr 30, 2023 · 0 comments

Comments

@aminmsvi
Copy link

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:

  1. Use Square's Wire library to make a gRPC call.
  2. Wait for the call to fail and throw a GrpcException.
  3. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant