Repository navigation
fix: send HTTP 200 for trailers-only gRPC errors - #16617
Conversation
Fixes apache#16608 Co-authored-by: Codex <noreply@openai.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16617 +/- ##
=============================================
+ Coverage 36.89% 61.24% +24.34%
- Complexity 11753 11759 +6
=============================================
Files 1952 1953 +1
Lines 89387 89415 +28
Branches 13420 13502 +82
=============================================
+ Hits 32983 54762 +21779
+ Misses 51800 29031 -22769
- Partials 4604 5622 +1018
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
EarthChen
left a comment
There was a problem hiding this comment.
Verified locally: applying the new test to the 3.3 head reproduces expected: <200> but was: <500> on all three trailers-only cases; with the fix they pass, and errorAfterHeadersDoesNotRepeatHttpStatus confirms trailers sent after headers no longer carry a second :status. The h12 test package passes (40 tests, 0 failures).
The fix is correctly scoped: overriding customizeTrailers in GrpcStreamServerChannelObserver runs after the base class writes resolveErrorStatusCode into :status and before the grpc-status customizers, so it only rewrites the trailers-only case and covers the unary and HTTP/3 gRPC observers via inheritance, while REST responses keep their HTTP error statuses as intended.
One note, not a blocker: the new tests mock the H2StreamChannel, so no test here drives the actual HTTP/2 wire path end to end — the curl-level reproduction in #16608 covers that layer manually. A follow-up integration test asserting :status 200 on a real triple round trip would lock the fix at the deployment layer too.
Summary
When a Triple gRPC call fails before sending headers, the reply currently carries HTTP 500 and the intended
grpc-status. Some gRPC clients treat the HTTP error as a transport status and lose the service error code. Send HTTP 200 in trailers-only gRPC replies and retain the existinggrpc-statuscustomization. Trailers sent after headers carry no second HTTP status.Fixes #16608.
Validation
On the original source, the new gRPC regression tests got HTTP 500 for INVALID_ARGUMENT, NOT_FOUND, and UNAUTHENTICATED. All four cases passed with the fix, including the streaming control after initial headers. The Linux fork runs the Triple module and its reactor dependencies with
mvn clean verify, including tests, checkstyle, and license checks.Validated source:
7b5a5c01dde73a9439f593fae3b6b9c92a4341c6.Codex assisted with implementation and testing.