client must not attempt decode responses with wrong content type
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Bug Report
When non-gRPC error is returned, for example 502 bad gateway by a proxy server, tonic client returns an error like
```
status: Internal, message: "protocol error: received message with invalid compression flag: 60 (valid flags are 0 and 1) while receiving response with status: 502 Bad Gateway", details: [], metadata: MetadataMap { headers: {"date": "Fri, 01 Aug 2025 02:23:45 GMT", "content-type": "text/html", "content-length": "150", "strict-transport-security": "max-age=31536000; includeSubDomains"} }
```
Content-type is not `application/grpc`, so attempt to read first byte as either 0 or 1 for compression is incorrect.
### Version
0.13
Error comes from here:
https://github.com/hyperium/tonic/blob/87d2d4c5055eae231318bab6c8c94fbd466a7750/tonic/src/codec/decode.rs#L176
Contributor guide
Assessment
This issue has not been assessed yet.