Skip to content

Surface response body when receiving an unexpected status code and content-type #7406

Description

@drigz

Use case(s) - what problem will this feature solve?

When using a gRPC server through a reverse proxy, the client will sometimes see plaintext or HTML error served by the proxy. Currently, the user of the gRPC client just sees:

rpc error: code = Unknown desc = unexpected HTTP status code received from server: 500 (Internal Server Error); transport: received unexpected content-type "text/html"

Proposed Solution

It would be more helpful if the response body was included in the error, for example:

rpc error: code = Unknown desc = unexpected HTTP status code received from server: 500 (Internal Server Error); transport: received unexpected content-type "text/html"; response body:
<first N bytes of the response body if printable>

Alternatives Considered

This could also be added to the status details, so that they can be shown like this: https://jbrandhorst.com/post/grpc-errors/#:~:text=In%20order%20to%20extract%20these%20errors%20on%20the%20other%20side

Although of course this requires some more code on the client side, maybe not all users want to see the response body, as especially nginx can serve massive amounts of boilerplate HTML in its errors.

Additional Context

#1924 (comment) commented:

Still not returning the raw HTML, however, but I think we should cover that with a separate feature request instead of as part of this bug.

But I can't find that the FR was ever filed.

Metadata

Metadata

Assignees

Labels

Area: TransportIncludes HTTP/2 client/server and HTTP server handler transports and advanced transport features.P2Type: FeatureNew features or improvements in behavior

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions