api7 / api7/aisix

aisix-a2a: an SSE frame whose JSON-RPC envelope spans several data: lines fails the stream

Open
#1,143 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
157
Forks
32
Avg merge
1h 25m
Merged PRs (30d)
145

Description

aisix-a2a's SSE relay reads one data: line as one JSON-RPC envelope, so an agent that spells a long envelope across several data: lines fails the whole stream rather than being read.

sse_events (crates/aisix-a2a/src/bridge.rs) splits the byte stream on \n and hands each line to parse_sse_data_line, which does strip_prefix("data:") and parses the remainder as a complete envelope. The event-stream spec joins a frame's data: lines with \n into one payload, so a continued envelope arrives as two invalid fragments — and the first one returns A2aError::Request("malformed JSON-RPC event"), whose arm returns and ends the stream mid-task.

The assumption is deliberate and documented in that function's doc comment ("A2A carries one JSON-RPC envelope per data: line"), which is why #1142 fixed the same reader class in aisix-proxy and left this one alone rather than changing it silently. Closing it is not a one-line edit: it moves the relay from line framing to frame framing, and with that the point at which a malformed line fails the stream — today the first bad line fails immediately, whereas a frame reader has to buffer to the blank line before it can decide. That trade is worth making deliberately.

Same class as #1105 and #1100.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in crates/aisix-a2a/src/bridge.rs by reading sse_events and parse_sse_data_line, including the documented one-envelope-per-data-line assumption. Compare the related aisix-proxy reader change in #1142 and review #1105 and #1100 for context. Done means an SSE frame can join multiple data: lines into one JSON-RPC envelope while preserving deliberate malformed-frame error behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.