Skip to content

fix: remove unreachable error check inside thread event block#3462

Open
ZAID646 wants to merge 1 commit into
openai:mainfrom
ZAID646:fix/unreachable-error-check
Open

fix: remove unreachable error check inside thread event block#3462
ZAID646 wants to merge 1 commit into
openai:mainfrom
ZAID646:fix/unreachable-error-check

Conversation

@ZAID646

@ZAID646 ZAID646 commented Jul 1, 2026

Copy link
Copy Markdown

In src/openai/_streaming.py, both the sync and async __stream__ methods contain a dead code block:

if sse.event and sse.event.startswith("thread."):
    data = sse.json()

    # DEAD CODE: "error" does not start with "thread.", so this check is unreachable
    if sse.event == "error" and is_mapping(data) and data.get("error"):
        ...
        raise APIError(...)

    yield process_data(...)

The sse.event == "error" check inside the sse.event.startswith("thread.") block can never be true. This was a regression from commit abc25966 where the error check was incorrectly moved inside the thread branch during a refactor. The else branch already handles errors correctly for non-thread events.

Fixes #2796

@ZAID646 ZAID646 requested a review from a team as a code owner July 1, 2026 18:00
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.

Bug: Dead code - sse.event == "error" check is unreachable in _streaming.py

1 participant