Skip to content

transport: return unexpected EOF for partial reads - #9204

Merged
easwars merged 5 commits into
grpc:masterfrom
buger:codex/fix-transport-partial-header-eof
Sep 9, 2026
Merged

easwars merged 5 commits into
grpc:masterfrom
buger:codex/fix-transport-partial-header-eof

Conversation

@buger

@buger buger commented Jun 27, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #9200

Track cumulative bytes read while filling a gRPC message header or body. If EOF occurs after any partial progress, return io.ErrUnexpectedEOF even when the final read call itself returned zero bytes. Preserve plain io.EOF when EOF occurs before any data is read.

Regression tests split partial headers and bodies from EOF across separate receive-buffer messages. They verify that partial reads return io.ErrUnexpectedEOF while zero-progress reads retain io.EOF.

RELEASE NOTES:

  • transport: Truncated gRPC message headers and bodies now return io.ErrUnexpectedEOF after partial data is received.

@codecov

codecov Bot commented Jun 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.53%. Comparing base (298389d) to head (f1360ff).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9204      +/-   ##
==========================================
+ Coverage   87.47%   87.53%   +0.06%     
==========================================
  Files         429      429              
  Lines       30644    30650       +6     
==========================================
+ Hits        26805    26829      +24     
+ Misses       3839     3820      -19     
- Partials        0        1       +1     
Files with missing lines Coverage Δ
internal/transport/transport.go 94.02% <100.00%> (+1.32%) ⬆️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@buger
buger marked this pull request as ready for review June 27, 2026 08:52
@mbissa
mbissa self-requested a review June 30, 2026 03:45
@easwars easwars added this to the 1.84 Release milestone Jul 14, 2026
@mbissa

mbissa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies ReadMessageHeader in internal/transport/transport.go to track the total bytes read across multiple iterations using a new bytesRead variable, ensuring io.ErrUnexpectedEOF is correctly returned if a partial header is read before EOF. A new unit test, TestReadMessageHeaderPartialHeaderEOF, is added to verify this behavior. The reviewer noted that the test method shadows its receiver variable s with a local variable of the same name, and suggested renaming the local variable to stream to improve code clarity and maintainability.

Comment thread internal/transport/transport_test.go Resolved
Comment thread internal/transport/transport_test.go Resolved
@mbissa

mbissa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Thanks @buger for the contribution, can you please address the comments once?

@buger
buger force-pushed the codex/fix-transport-partial-header-eof branch from 26d88f7 to 472254d Compare July 28, 2026 11:11
@buger

buger commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @mbissa, I updated this PR to address the review comments.

Changes applied:

  • renamed the local Stream variable in TestReadMessageHeaderPartialHeaderEOF to avoid shadowing the receiver
  • added a separate EOF-only negative test to verify recvMsg{err: io.EOF} is reported as io.EOF and not io.ErrUnexpectedEOF

Local validation passed:

go test ./internal/transport -run '^Test/ReadMessageHeader' -count=1
git diff --check

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed.

@github-actions github-actions Bot added the stale label Aug 3, 2026
@buger

buger commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@mbissa, I have now replied directly to both review threads and resolved them after re-verifying the requested changes in 472254d. The full internal/transport package passes locally with go test ./internal/transport -count=1.

Could you please re-review when convenient and clear Status: Requires Reporter Clarification? The PR is currently also marked stale.

@mbissa mbissa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, assigning to @easwars for second set of eyes.

@mbissa mbissa assigned easwars and unassigned mbissa Aug 24, 2026

@easwars easwars left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies for the delay in reviewing this change.

Comment thread internal/transport/transport_test.go Resolved
Comment thread internal/transport/transport.go Resolved
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

This PR is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed.

@github-actions github-actions Bot added the stale label Sep 7, 2026
@buger buger changed the title transport: return unexpected EOF for partial headers transport: return unexpected EOF for partial reads Sep 7, 2026
@buger

buger commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@easwars, I addressed both review comments and replied inline. The partial-message read now uses cumulative progress so EOF after prior bytes becomes io.ErrUnexpectedEOF, while zero-progress EOF remains io.EOF; focused tests cover both boundaries. I also updated the test window handler to the suggested non-nil no-op.

The branch is now current with master, and the complete CI matrix is green. Could you please re-review when convenient and clear Status: Requires Reporter Clarification?

@github-actions github-actions Bot removed the stale label Sep 7, 2026
@easwars

easwars commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution, @buger

@easwars
easwars merged commit a9cbf17 into grpc:master Sep 9, 2026
20 checks passed
Pranjali-2501 added a commit that referenced this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transport: return unexpected EOF for partial message headers

4 participants