You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c8ccea9
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(client): split SSE lines only on CR, LF and CRLF (a2aproject#1456)
# Description
`parse_sse_stream` read the stream with `response.aiter_lines()`, which
follows `str.splitlines()` and also ends a line at U+2028, U+2029 and
U+0085. The server writes these characters raw inside one `data:` line,
so the client cut the event short and the payload failed to parse.
As suggested in a2aproject#1432, the fix is in `parse_sse_stream`. Lines now come
from `aiter_text()` and end only at CRLF, LF or CR, as the [SSE
specification](https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream)
requires. A CR at the end of a chunk is held back, so a CRLF split
across two chunks still ends one line.
Tests:
- `test_parse_sse_stream_ends_lines_only_at_cr_or_lf` feeds real
`httpx.Response` byte chunks through the parser:
- the three separators inside `data:`
- a CRLF and a U+2028 byte sequence each split across chunks
- an event with no closing blank line, which is still not dispatched
- Transport tests that mocked `aiter_lines()` now mock `aiter_text()`.
`./scripts/lint.sh` and `uv run pytest` pass. Coverage on
`http_helpers.py` is 93%.
- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- [x] Ensure the tests and linter pass (Run `bash scripts/format.sh`
from the repository root to format)
- [x] Appropriate docs were updated (if necessary)
Fixesa2aproject#1432 🦕
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Mateusz Iwaniuk <45974414+Iwaniukooo11@users.noreply.github.com>
0 commit comments