Skip to content

feat(grpc): Add server-side stream validators#2595

Closed
sauravzg wants to merge 2 commits intohyperium:masterfrom
sauravzg:sauravz/server-stream-validators
Closed

feat(grpc): Add server-side stream validators#2595
sauravzg wants to merge 2 commits intohyperium:masterfrom
sauravzg: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.

@sauravzg sauravzg requested a review from dfawley April 17, 2026 17:07
@sauravzg sauravzg force-pushed the sauravz/server-stream-validators branch from cc729c2 to c6e486a Compare April 17, 2026 17:08
@dfawley
Copy link
Copy Markdown
Collaborator

dfawley commented Apr 17, 2026

As discussed offline, we likely should move Trailers to be a return value from the handler instead of being an item on the stream, which would impact this PR (likely making it simpler since there's less ordering to enforce).

@sauravzg
Copy link
Copy Markdown
Collaborator Author

Back from OOO. ETA for addressing comment: 1d , since I need to catch up to a few things first.

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 c6e486a to c5d8980 Compare April 23, 2026 18:13
@sauravzg
Copy link
Copy Markdown
Collaborator Author

I'll close this PR and create a new one, since it's painful to do stacked PR workflow from fork.

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.

2 participants