Skip to content

fix: surface data when received non-grpc header, end stream without trailers#9217

Open
chengxilo wants to merge 1 commit into
grpc:masterfrom
chengxilo:follow-up-surface-non-grpc-data
Open

fix: surface data when received non-grpc header, end stream without trailers#9217
chengxilo wants to merge 1 commit into
grpc:masterfrom
chengxilo:follow-up-surface-non-grpc-data

Conversation

@chengxilo

@chengxilo chengxilo commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Follow up: #8929

Related to: #7406 (comment) . I don't have the captured packages for reference. But according to the code, I think what I fixed is the only code path that produces codes.Internal / "server closed the stream without sending trailers" when nonGRPCStatus is set.

With this change, if we were collecting non-gRPC response data, and received an end of stream while there is no trailers, finalize the status with whatever body we've buffered so far instead of discarding it. I added tests in both internal/transport_test.go and test/end2end_test.go to test it.

RELEASE NOTES:

  • client: Fix non-gRPC error being discarded when END_STREAM arrives without trailers

If we were collecting non-gRPC response data, finalize the status with whatever
 body we've buffered so far instead of discarding it. Add tests in both
internal/transport_test.go and test/end2end_test.go to test it.
@chengxilo chengxilo changed the title fix: surface data when end stream without trailers fix: surface data when received non-grpc header, end stream without trailers Jul 1, 2026
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.22%. Comparing base (5013974) to head (fbb26c5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9217      +/-   ##
==========================================
- Coverage   83.27%   83.22%   -0.05%     
==========================================
  Files         420      420              
  Lines       34022    34028       +6     
==========================================
- Hits        28331    28319      -12     
- Misses       4262     4278      +16     
- Partials     1429     1431       +2     
Files with missing lines Coverage Δ
internal/transport/http2_client.go 92.34% <100.00%> (-0.26%) ⬇️

... and 30 files with indirect coverage changes

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

@drigz

drigz commented Jul 3, 2026

Copy link
Copy Markdown

I can confirm this works:

Error: API call failed: rpc error: code = Unauthenticated desc = unexpected HTTP status code received from server: 401 (Unauthorized); transport: received unexpected content-type "text/html"
data: "<html>\r\n<head><title>401 Authorization Required</title></head>\r\n<body>\r\n<center><h1>401 Authorization Required</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"

Thank you for the quick followup! Looking forward to pulling the next release in and enjoying more discoverable error messages.

@chengxilo

Copy link
Copy Markdown
Contributor Author

I can confirm this works:

Error: API call failed: rpc error: code = Unauthenticated desc = unexpected HTTP status code received from server: 401 (Unauthorized); transport: received unexpected content-type "text/html"
data: "<html>\r\n<head><title>401 Authorization Required</title></head>\r\n<body>\r\n<center><h1>401 Authorization Required</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"

Thank you for the quick followup! Looking forward to pulling the next release in and enjoying more discoverable error messages.

Great!!! Thank you so much for your quick followup too! ❤️❤️❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants