Skip to content

client must not attempt decode responses with wrong content type #2365

@stepancheg

Description

@stepancheg

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:

"protocol error: received message with invalid compression flag: {f} (valid flags are 0 and 1) while receiving response with status: {status}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions