Skip to content

Fix bad transition when server sends invalid headers in stream state machine #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Apr 10, 2025

While triaging #83 we discovered an issue with the stream state machine, where we would not transition the server to closed when receiving invalid headers. This is not correct, because at this point the server is in an unrecoverable state from the client's perspective, and we should ignore any subsequent messages.

This PR fixes this transition, which was causing an "invalid state" error (or runtime crash in debug mode). It now drops any further messages from the server on the floor, instead of throwing/sending another error message back to the client.

I've also fixed a problem with receiving headers with a 1xx status code: they should be ignored, but we were transitioning to closed states instead.

@gjcairo gjcairo added the 🔨 semver/patch No public API change. label Apr 10, 2025
@gjcairo gjcairo requested a review from glbrntt April 10, 2025 16:31
buffer.writeInteger(UInt8(0)) // not compressed
buffer.writeInteger(UInt32(42)) // message length
buffer.writeRepeatingByte(0, count: 42) // message
let serverDataPayload = HTTP2Frame.FramePayload.Data(data: .byteBuffer(buffer), endStream: true)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What about the server sending trailers with end stream set? We should cover that case as well.

@gjcairo gjcairo requested a review from glbrntt April 14, 2025 17:01
@gjcairo gjcairo force-pushed the fix-bad-transition branch from 9a6a17b to b0b2097 Compare April 14, 2025 17:02
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Thanks Gus!

@glbrntt glbrntt merged commit 699ebb8 into grpc:main Apr 15, 2025
28 of 29 checks passed
@gjcairo gjcairo deleted the fix-bad-transition branch April 15, 2025 09:27
dongjoon-hyun added a commit to apache/spark-connect-swift that referenced this pull request May 14, 2025
### What changes were proposed in this pull request?

This PR aims to upgrade `gRPC Swift NIO Transport` library to 1.1.0.

### Why are the changes needed?

To bring the latest big fixes with the official Swift 6.1 tested version.
- https://github.com/grpc/grpc-swift-nio-transport/releases/tag/1.1.0
  - grpc/grpc-swift-nio-transport#88
  - grpc/grpc-swift-nio-transport#94
  - grpc/grpc-swift-nio-transport#89

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Pass the CIs.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #147 from dongjoon-hyun/SPARK-52138.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants