fix(a2a): parse multi-line SSE events - #1155
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe SSE relay now buffers complete events, joins multiple ChangesSSE frame reassembly
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~20 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to A2A SSE streams can now carry JSON-RPC envelopes across multiple data fields without premature parse failures. The updated framing and size-limit behavior are covered by targeted unit and integration tests, with no current merge-blocking risk identified. Suggested reviewers: 🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Fixes #1143.
An A2A agent can split a JSON-RPC envelope across several
data:fields in one SSE event. The relay previously parsed each line separately and terminated the stream on the first incomplete JSON fragment.Buffer until the event's blank line, join its data fields with newlines, and parse the envelope once, following the SSE event-stream rules. This handles LF/CRLF framing and network chunk boundaries while ignoring comments and metadata. The existing 16 MiB limit now bounds the accumulated event. Existing compatibility for an unterminated final event is retained.
Malformed JSON is now reported when the complete event arrives, or at EOF, rather than after its first data line. Existing configurations need no changes.
Regression coverage includes multiline payloads, interspersed metadata, split CRLF/JSON writes, malformed JSON, and an oversized event made of individually small lines. The HTTP round-trip regression fails against the original reader with
malformed JSON-RPC eventand passes with this change.Validation
Validated on Rust 1.93.1 in a Linux checkout, at commit
7f73bb63b569288a3284559dcbb28d741c911567:cargo fmt --all --checkpassed.cargo check --locked --workspacepassed.cargo clippy --locked --workspace -- -D warningspassed.cargo test --locked --workspace --no-fail-fasthas one failing test:aisix-mcp::bridge::tests::connect_timeout_bounds_an_unreachable_upstream.The same full-workspace test command, in the same environment, on unmodified upstream
main(c8e96aa) fails only that same MCP test. It exceeds the test's eight-second bound while reaching the unreachable test address. No tests were skipped or weakened to hide this failure. Local proxy/network behavior affects this test, so this draft does not claim a green full-workspace test run; upstream CI still needs to validate it.The separate repository E2E suite has not been run locally. This change is limited to the A2A reader and its tests.
Summary by CodeRabbit