Skip to content

fix(streaming): preserve first SSE event after BOM - #3819

Open
Hughhhhcoder wants to merge 1 commit into
openai:mainfrom
Hughhhhcoder:codex/openai-python-sse-bom
Open

fix(streaming): preserve first SSE event after BOM#3819
Hughhhhcoder wants to merge 1 commit into
openai:mainfrom
Hughhhhcoder:codex/openai-python-sse-bom

Conversation

@Hughhhhcoder

Copy link
Copy Markdown
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Strip the single leading UTF-8 byte-order mark allowed by the SSE format before interpreting the first line.

Today SSEDecoder decodes each completed line independently. A valid stream beginning with a BOM therefore presents its first field as \ufeffdata instead of data, so the decoder silently drops the first event. The WHATWG event-stream interpretation algorithm explicitly strips one leading UTF-8 BOM.

The decoder now tracks the first line of each stream and removes only a leading BOM there. The regression covers synchronous and asynchronous decoding with the three BOM bytes both contiguous and split across input chunks.

Additional context & links

Validation:

  • uv run --locked --all-extras pytest tests/test_sse_framing.py — 48 passed
  • ./scripts/test-pydantic-v1 tests/test_sse_framing.py — 48 passed
  • ./scripts/lint — Ruff, Pyright, Mypy, and import checks passed
  • Castiron custom-code budget check — passed (6,626 / 10,000 lines)
  • git diff --check origin/main...HEAD — passed

@Hughhhhcoder
Hughhhhcoder requested a review from a team as a code owner September 8, 2026 06:33
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-08T06:36:21.400904Z 3601840 PR opened
🔒 Security Review Completed 2026-09-08T06:39:47.959125Z 3601840 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant