core: Clarify missing content-type on HTTP error responses#12720
Open
becomeStar wants to merge 1 commit intogrpc:masterfrom
Open
core: Clarify missing content-type on HTTP error responses#12720becomeStar wants to merge 1 commit intogrpc:masterfrom
becomeStar wants to merge 1 commit intogrpc:masterfrom
Conversation
Improve the client-side diagnostic for HTTP error responses that are missing `content-type`. grpc-java currently may report a missing header as `invalid content-type: null`. Keep the existing HTTP-to-gRPC status mapping unchanged and replace that detail with a more accurate message.
There was a problem hiding this comment.
Pull request overview
This PR improves gRPC-Java client diagnostics when an HTTP error response is missing the content-type header, replacing the misleading invalid content-type: null message while keeping the existing HTTP→gRPC status mapping unchanged (per #12418).
Changes:
- Adjust
Http2ClientStreamTransportState.validateInitialMetadata()to emitmissing content-type in response headerswhen the header is absent (null). - Preserve existing behavior/messages for invalid non-null content-type values.
- Add a regression test covering missing
content-typewith an HTTP 431 response.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/main/java/io/grpc/internal/Http2ClientStreamTransportState.java | Emits a clearer diagnostic when content-type is missing while keeping HTTP status mapping intact. |
| core/src/test/java/io/grpc/internal/Http2ClientStreamTransportStateTest.java | Adds test coverage for the missing content-type + HTTP 431 case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
/gcbrun |
kannanjgithub
approved these changes
Mar 23, 2026
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.
Summary
In this case, grpc-java preserves the HTTP status-based context, but may later append
invalid content-type: null.That seems misleading when the response is missing
content-type, because the header appears to be absent rather than invalid, and thenullvalue exposes a Java implementation detail.This PR keeps the existing HTTP-to-gRPC status mapping unchanged and only adjusts the diagnostic for the missing
content-typecase.Changes
invalid content-type: nullwithmissing content-type in response headersRef #12418