Skip to content

fix(client): decode SSE streams as UTF-8 - #1489

Open
SoroushRF wants to merge 1 commit into
a2aproject:mainfrom
SoroushRF:fix/sse-utf8-decoding
Open

SoroushRF wants to merge 1 commit into
a2aproject:mainfrom
SoroushRF:fix/sse-utf8-decoding

Conversation

@SoroushRF

Copy link
Copy Markdown

The REST and JSON-RPC streaming clients share an SSE reader that delegates decoding to HTTPX or HTTPX2. When the response declares an ISO-8859-1 charset or the caller sets an ISO-8859-1 client default, a valid UTF-8 SSE payload such as café 東京 comes back corrupted. The SSE standard requires UTF-8 decoding.

Read response bytes, keep the existing CR, LF, and CRLF framing, and decode each complete line as UTF-8. The regression feeds one byte at a time so both multibyte characters and CRLF cross chunk boundaries. #1259 covers leading byte-order mark handling.

Validation

  • On upstream 0fc0d3a, both charset override cases corrupted the payload and the UTF-8 control passed. The fix passes all three cases with HTTPX and HTTPX2.
  • All 174 client transport tests and 1,167 HTTPX2-marked tests passed.
  • The full Ubuntu suite and coverage run each reported 2,628 passed, 215 skipped, 4 expected failures, and 1 unexpected pass. Coverage was 93.73%. PostgreSQL and MySQL service-dependent cases were skipped.
  • scripts/lint.sh and uv build passed.

OpenAI Codex helped investigate, implement, and test this change.

Read SSE response bytes and decode complete lines as UTF-8. Preserve CR, LF and CRLF framing across chunks, regardless of HTTP charset hints or client defaults.
@SoroushRF
SoroushRF requested a review from a team as a code owner November 18, 2026 03:09
@github-actions

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

No coverage changes.

Generated by coverage-comment.yml

This branch has not been deployed

No deployments
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