Reject invalid gRPC responses and preserve HTTP diagnostics - #10
Merged
Merged
Conversation
This was referenced Sep 24, 2026
samuel-williams-shopify
marked this pull request as ready for review
September 24, 2026 01:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An HTML error response from a server or proxy currently enters the gRPC frame decoder and produces a misleading truncated-frame error. Reject responses unless they have HTTP status 200 and a gRPC content type, raising
Async::GRPC::ResponseErrorbefore decoding frames.The client raises
ResponseError.for(response). This factory builds a descriptive message and passes it withresponse.buffered!toinitialize(message, response). Callers can inspect status and headers througherror.responseand read the raw body througherror.response.read. Buffering closes the network body throughBody#each, including when reading raises. Invalid responses are not interpreted for gRPC status; valid gRPC responses retain their existing status and trailer handling.Validation buffers the full body before raising the error, so it waits for body completion and stores that body in memory. The compatibility adapter in socketry/async-grpc-compatible#7 applies the HTTP-to-gRPC status mapping and retains this error as the cause. For example, an HTML HTTP 503 becomes
GRPC::Unavailablewith the HTML accessible througherror.cause.response.read.Requests use
application/grpc. Require the releasedprotocol-grpc ~> 0.16dependency, with dispatcher integration tests confirming server backtraces are omitted by default.Addresses the shared client behavior for:
Includes integration coverage for socketry/protocol-grpc#16. Downstream compatibility integration: socketry/async-grpc-compatible#7.
Transport-error conversion is separate work tracked by socketry/async-grpc-compatible#5. This PR preserves native transport exceptions and adds no response-body wrapper.
Validation:
COVERAGE=PartialSummary bundle exec bake test(84 tests, 201 assertions; 100% line coverage),bundle exec rubocop, andbundle exec bake decode:index:coverage lib(29/29 public definitions). Tested on Ruby 4.0.7 against protocol-grpc 0.16.0, including HTTP/1 and HTTP/2 integration tests. The dependent compatibility suite also passes (55 tests, 224 assertions), including HTTP/2 coverage for status mapping, retained bodies, headers, and response cleanup.CI note: the experimental TruffleRuby job on the preceding revision failed in Async/test fixture setup because
Fiber.scheduleris unavailable. That matrix entry is configured withcontinue-on-error.