Skip to content

fix(streaming): validate SSE retry digits - #3835

Open
sylvesterkaczmarek wants to merge 2 commits into
openai:mainfrom
sylvesterkaczmarek:fix-sse-retry-ascii-digits
Open

fix(streaming): validate SSE retry digits#3835
sylvesterkaczmarek wants to merge 2 commits into
openai:mainfrom
sylvesterkaczmarek:fix-sse-retry-ascii-digits

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

  • accept SSE retry values only when every character is an ASCII digit
  • preserve an earlier valid retry value when a later invalid field is ignored
  • add coverage for signed, Unicode, decimal, underscore, and zero-padded values

Fixes #3834

Tests

Regression coverage added in tests/test_sse_retry_validation.py. The connected development host was unavailable for a local suite run.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner September 10, 2026 02:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 10, 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-10T02:19:26.985843Z a211616 PR opened
🔒 Security Review Completed 2026-09-10T02:24:07.624252Z a211616 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a211616bff

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/openai/_streaming.py
elif fieldname == "retry":
try:
if value.isascii() and value.isdigit():
self._retry = int(value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep oversized retry fields from aborting streams

When an SSE endpoint emits a digit-only retry field longer than CPython's configured integer-conversion limit (4,300 digits by default on supported versions), this condition passes but int(value) raises ValueError, aborting both synchronous and asynchronous stream iteration. The prior try/except safely ignored such a field, so retain conversion error handling after the ASCII-digit validation.

AGENTS.md reference: AGENTS.md:L112-L121

Useful? React with 👍 / 👎.

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.

SSE decoder accepts invalid retry field values

1 participant