fix(http): enforce bounded WebSocket request handling - #315
Draft
muharshad0311-source wants to merge 2 commits into
Draft
fix(http): enforce bounded WebSocket request handling#315muharshad0311-source wants to merge 2 commits into
muharshad0311-source wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
WebSocketLimitsbuilder to the ACP HTTP serverMessageTooLongfailures to WebSocket close code 1009This provides a generic transport boundary for downstream servers such as
aaif-goose/goose(issue #10751), where one physical WebSocket can carry multiple ACP sessions.Behavior
-32600and structuredpayload_too_largesize metadata.id: nullremains distinguishable from a notification and receives a correlated null-ID error response.id: null; notifications and response-shaped entries do not receive pseudo-responses.1009(Message Too Big). The physical socket and all sessions on it are then cleaned up.RawValueentries to validate the remaining JSON; it does not collect request IDs or expand input into an unbounded side structure.Safety and compatibility
AcpHttpServerbehavior remains unchanged unless the builder is called.ServerOptionsis unchanged, preserving downstream struct literals.RawValuebatch entries through a narrow envelope visitor and bounded writer. It examines only JSON-RPC envelope fields and does not materializeparams, prompt text, or base64 data before rejecting an oversized request.Dispatch,OutgoingMessage, typed requests, session updates, or params. Soft-limit logs contain only connection/category/count/size metadata; client-controlled request IDs are not logged by the exercised core or WebSocket path.error.datais removed. Typed JSON conversion failures retain only a fixed phase marker—never the original JSON or Serde error text—so structurally valid but typed-invalid prompts cannot echo prompt or base64 content into logs or JSON-RPC errors.=0.8.9, and the direct Tungstenite dependency is pinned to exactly 0.29.0, so the typed downcast cannot silently split across crate identities. In the independently resolvedserverfeature stack, the direct dependency and Axum both use Tungstenite 0.29. The separate client feature may resolve Tungstenite 0.30 throughasync-tungstenite; that type is not used by the Axum server error downcast.Tests
The regression matrix covers below/exact/above-soft requests, numeric/null/string request IDs, single and mixed batches, dense invalid batch entries, notification/response filtering, malformed response-shaped input, valid and typed-invalid text-and-image prompts through a real protocol actor, a typed callback response and session update carrying sensitive content, serializer-failure redaction, same-socket continuation by another session, outbound ordering, bounded generated responses, cross-target accepted/rejected/malformed log redaction, frame and message hard limits, close 1009, malformed JSON continuation, non-capacity errors, and connection cleanup.
The unexcluded repository-wide command reaches an unchanged conductor integration test and then fails in
test_nested_conductor_with_external_arrow_proxieswithIncoming transport closed. The conductor dependency tree contains noagent-client-protocol-http; excluding that package makes the remainder of the workspace green. This PR does not modify conductor code.Maintainer feedback requested
-32600the preferred JSON-RPC error code for a syntactically valid request rejected by this transport policy?