Skip to content

fix: map no trailers ok status to unknown#2543

Merged
LucioFranco merged 7 commits into
grpc:masterfrom
qube-rt:master
Mar 24, 2026
Merged

fix: map no trailers ok status to unknown#2543
LucioFranco merged 7 commits into
grpc:masterfrom
qube-rt:master

Conversation

@rumenov

@rumenov rumenov commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Motivation

The change updates gRPC status handling so that HTTP 200 responses missing grpc-status trailers are treated as internal errors instead of silently completing. A new integration test simulates a truncated response to ensure clients surface the issue. This prevents data loss scenarios from being masked as successful completions.
Clients will now see explicit internal errors when a streaming response ends without grpc-status trailers, preventing silent data loss. The new integration test guards this behavior against future regressions.

Solution

  1. gRPC Status Mapping
    Adjusted tonic’s infer_grpc_status logic to treat missing trailers as protocol violations.
    http 200 responses without grpc-status trailers now return an internal Status error instead of appearing as clean end-of-stream.
    Expanded comments explaining protocol expectations and rationale for mapping to Internal.
    Clarified that h2::Reason::NO_ERROR on RST_STREAM signals missing grpc-status trailers.

  2. Integration Test Coverage
    Added an integration test that simulates a truncated server response to verify the new error mapping.
    Introduced TruncatedBody and tower layer to cut off the response before trailers.
    Created missing_grpc_status_trailer_is_internal_error test ensuring client surfaces tonic::Code::Internal.
    Verified error message contains 'missing grpc-status trailer' to guard against regressions.

@rumenov rumenov changed the title map no trailers ok status to internal fix: map no trailers ok status to internal Mar 10, 2026
Comment thread tonic/src/status.rs Outdated
Comment thread tests/integration_tests/tests/status.rs Outdated
Comment thread tests/integration_tests/tests/status.rs Outdated

@dfawley dfawley 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.

This looks good in premise to me, though I am admittedly not an expert in the inner workings of tonic to say whether it's the best fix (though I do suspect it is).

@dfawley

dfawley commented Mar 20, 2026

Copy link
Copy Markdown
Member

(Though the new tests also need to be adjusted to the new status code.)

@rumenov rumenov changed the title fix: map no trailers ok status to internal fix: map no trailers ok status to unknown Mar 21, 2026
Rostislav Rumenov added 2 commits March 22, 2026 21:55

@dfawley dfawley 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.

Thank you for the test updates. This looks great, but one very small request for the comments.

Comment thread tests/integration_tests/tests/status.rs
Comment thread tests/integration_tests/tests/status.rs
Comment thread tests/integration_tests/tests/status.rs Outdated
@rumenov

rumenov commented Mar 23, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the test updates. This looks great, but one very small request for the comments.

Updated

@dfawley dfawley requested a review from LucioFranco March 23, 2026 20:42
@dfawley dfawley assigned LucioFranco and unassigned rumenov Mar 23, 2026
@LucioFranco

Copy link
Copy Markdown
Member

Thanks!

@LucioFranco LucioFranco merged commit 3ab377b into grpc:master Mar 24, 2026
21 checks passed
@github-actions github-actions Bot mentioned this pull request May 4, 2026
LucioFranco pushed a commit that referenced this pull request May 7, 2026
## 🤖 New release

* `tonic`: 0.14.5 -> 0.14.6 (✓ API compatible changes)
* `tonic-build`: 0.14.5 -> 0.14.6 (✓ API compatible changes)
* `tonic-prost`: 0.14.5 -> 0.14.6 (✓ API compatible changes)
* `tonic-health`: 0.14.5 -> 0.14.6 (✓ API compatible changes)
* `tonic-types`: 0.14.5 -> 0.14.6 (✓ API compatible changes)
* `tonic-reflection`: 0.14.5 -> 0.14.6 (✓ API compatible changes)
* `tonic-prost-build`: 0.14.5 -> 0.14.6 (✓ API compatible changes)
* `tonic-web`: 0.14.5 -> 0.14.6 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `tonic`

<blockquote>

##
[0.14.6](tonic-v0.14.5...tonic-v0.14.6)
- 2026-05-06

### Added

- *(transport/channel)* expose ServerCertVerifier API
([#2612](#2612))

### Fixed

- map no trailers ok status to unknown
([#2543](#2543))

### Other

- add max_frame_size to client Endpoint
([#2592](#2592))
- Allow setting the HTTP/2 client header table size
([#2582](#2582))
- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>

## `tonic-build`

<blockquote>

##
[0.14.6](tonic-build-v0.14.5...tonic-build-v0.14.6)
- 2026-05-06

### Other

- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>

## `tonic-prost`

<blockquote>

##
[0.14.6](tonic-prost-v0.14.5...tonic-prost-v0.14.6)
- 2026-05-06

### Other

- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>

## `tonic-health`

<blockquote>

##
[0.14.6](tonic-health-v0.14.5...tonic-health-v0.14.6)
- 2026-05-06

### Other

- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>

## `tonic-types`

<blockquote>

##
[0.14.6](tonic-types-v0.14.5...tonic-types-v0.14.6)
- 2026-05-06

### Other

- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>

## `tonic-reflection`

<blockquote>

##
[0.14.6](tonic-reflection-v0.14.5...tonic-reflection-v0.14.6)
- 2026-05-06

### Other

- fix panic when client drops connection early
([#2596](#2596))
- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>

## `tonic-prost-build`

<blockquote>

##
[0.14.6](tonic-prost-build-v0.14.5...tonic-prost-build-v0.14.6)
- 2026-05-06

### Other

- Support well known types resolved by prost to their rust counterparts
([#2544](#2544))
- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>

## `tonic-web`

<blockquote>

##
[0.14.6](tonic-web-v0.14.5...tonic-web-v0.14.6)
- 2026-05-06

### Other

- update rust edition and version to 2024 and 1.88, respectively
([#2525](#2525))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants