Skip to content

fix: send HTTP 200 for trailers-only gRPC errors - #16617

Merged
EarthChen merged 1 commit into
apache:3.3from
lanqing431:fix/grpc-trailers-http-status
Nov 28, 2026
Merged

EarthChen merged 1 commit into
apache:3.3from
lanqing431:fix/grpc-trailers-http-status

Conversation

@lanqing431

Copy link
Copy Markdown
Contributor

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 existing grpc-status customization. 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.

Fixes apache#16608

Co-authored-by: Codex <noreply@openai.com>
@codecov-commenter

codecov-commenter commented Nov 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.24%. Comparing base (b364f64) to head (7b5a5c0).
⚠️ Report is 1 commits behind head on 3.3.

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     
Flag Coverage Δ
integration-tests-java21 32.12% <50.00%> (+0.03%) ⬆️
integration-tests-java8 32.15% <50.00%> (-0.06%) ⬇️
samples-tests-java21 32.09% <0.00%> (+0.04%) ⬆️
samples-tests-java8 29.75% <0.00%> (+0.06%) ⬆️
unit-tests-java11 59.51% <100.00%> (?)
unit-tests-java17 58.99% <100.00%> (?)
unit-tests-java21 58.95% <100.00%> (?)
unit-tests-java25 58.94% <100.00%> (?)
unit-tests-java8 59.55% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EarthChen EarthChen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@EarthChen
EarthChen merged commit 2f0129b into apache:3.3 Nov 28, 2026
32 checks passed
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.

[Bug] Triple sends gRPC errors with HTTP :status 500, so dubbo-go and grpc-go clients lose the status code

3 participants