grpc_http1_reverse_bridge filter: support text errors from upstream
#12,953 opened on Sep 2, 2020
Repository metrics
- Stars
- (27,997 stars)
- PR merge metrics
- (Avg merge 8d) (378 merged PRs in 30d)
Description
Title: grpc_http1_reverse_bridge filter: support text errors from upstream
Description: Currently, the grpc_http1_reverse_bridge filter is configured with a single content_type that the upstream must respond with, or the filter stands in its own error (saying that the content type was wrong).
However, gRPC supports sending text error responses (see "Standard error model") here https://grpc.io/docs/guides/error/. This is exactly how the filter stands in its current error without needing to have knowledge of the response proto message.
It seems like it would make sense to allow configuring the filter to support passing text error message from the upstream to the downstream by using the grpc-message trailer as it currently does.
Proposal:
Add a pass_through_plaintext_errors bool to the filter's config. When set:
if upstream responds with anything other than 4xx or 5xx, and content type doesn't match the configured content-type, keep the behavior the same.
If the upstream responds with 4xx or 5xx, and the content type is something like text/plain, put it into grpc-message.
(Note that i'm not knowledgeable about MIME types so probably that's not an exhaustive list of what should be included, and maybe the exact allowable types should be configurable as well).