Skip to content

feat(grpc): add server-side stream validators#2602

Open
sauravzg wants to merge 1 commit intosauravz/handle-trailersfrom
sauravz/server-stream-validators
Open

feat(grpc): add server-side stream validators#2602
sauravzg wants to merge 1 commit intosauravz/handle-trailersfrom
sauravz/server-stream-validators

Conversation

@sauravzg
Copy link
Copy Markdown
Collaborator

Introduces ServerSendStreamValidator and ServerRecvStreamValidator to enforce strict gRPC semantics on server streams. These are intended to wrap raw transport streams before passing them to application-level handlers, ensuring that user-provided service logic cannot violate protocol rules.

  • ServerSendStreamValidator ensures proper response sequencing (Headers -> Messages -> Trailers) and prevents invalid state transitions, while fully supporting trailers-only responses.
  • ServerRecvStreamValidator safely manages terminal states, ensuring that any subsequent polls after stream completion consistently return an error to prevent undefined behavior.
  • Adds comprehensive unit tests to verify state machine correctness and protocol compliance.

This is recreation of #2595 to allow using a stacked PR workflow

@sauravzg sauravzg requested a review from dfawley April 23, 2026 18:21
@sauravzg sauravzg force-pushed the sauravz/handle-trailers branch from 507787e to e2f4bd0 Compare April 23, 2026 18:29
@sauravzg sauravzg force-pushed the sauravz/server-stream-validators branch from c5d8980 to c5c0e67 Compare April 23, 2026 18:29
Introduces `ServerSendStreamValidator` and `ServerRecvStreamValidator`
to enforce strict gRPC semantics on server streams. These are intended
to wrap raw transport streams before passing them to application-level
handlers, ensuring that user-provided service logic cannot violate
protocol rules.

- `ServerSendStreamValidator` ensures proper response sequencing
  (Headers -> Messages -> Trailers) and prevents invalid state
  transitions, while fully supporting trailers-only responses.
- `ServerRecvStreamValidator` safely manages terminal states, ensuring
  that any subsequent polls after stream completion consistently return
  an error to prevent undefined behavior.
- Adds comprehensive unit tests to verify state machine correctness and
  protocol compliance.
@sauravzg sauravzg force-pushed the sauravz/server-stream-validators branch from c5c0e67 to 038f365 Compare April 23, 2026 18:52
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.

1 participant