Skip to content

fix(streaming): strip leading UTF-8 BOM from event stream (#1982) - #1997

Open
iosayin wants to merge 1 commit into
anthropics:mainfrom
iosayin:fix/1982-sse-utf8-bom
Open

iosayin wants to merge 1 commit into
anthropics:mainfrom
iosayin:fix/1982-sse-utf8-bom

Conversation

@iosayin

@iosayin iosayin commented Oct 7, 2026

Copy link
Copy Markdown

Summary

Strips a leading UTF-8 Byte Order Mark (\xef\xbb\xbf / \ufeff) from the first line of an SSE event stream in SSEDecoder, complying with the WHATWG Server-Sent Events specification (event stream interpretation):

If line starts with a U+FEFF BYTE ORDER MARK character, remove that character from the line.

Previously, a leading BOM caused the first field (e.g. event: message_start) to be interpreted as \ufeffevent: message_start, missing the event type and failing JSON parsing or start event accumulation. Subsequent occurrences of \ufeff in later lines or data content are preserved intact.

Closes #1982

@iosayin
iosayin requested a review from a team as a code owner October 7, 2026 00:23

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.

A leading UTF-8 BOM prevents streaming messages from reading the first event

1 participant