From 09c2d66ce38bad1e7dbbb496cebd29e9135f0543 Mon Sep 17 00:00:00 2001 From: armorbreak001 Date: Wed, 22 Apr 2026 20:46:42 +0800 Subject: [PATCH] fix(streaming): remove unreachable error check in thread event handler The condition inside the event branch is always False since "error" never starts with "thread.". This makes the error-handling block dead code. Remove the redundant predicate so that thread events carrying error payloads are properly caught and raised as APIError. --- src/openai/_streaming.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openai/_streaming.py b/src/openai/_streaming.py index 45c13cc11d..6630556943 100644 --- a/src/openai/_streaming.py +++ b/src/openai/_streaming.py @@ -67,7 +67,7 @@ def __stream__(self) -> Iterator[_T]: if sse.event and sse.event.startswith("thread."): data = sse.json() - if sse.event == "error" and is_mapping(data) and data.get("error"): + if is_mapping(data) and data.get("error"): message = None error = data.get("error") if is_mapping(error): @@ -177,7 +177,7 @@ async def __stream__(self) -> AsyncIterator[_T]: if sse.event and sse.event.startswith("thread."): data = sse.json() - if sse.event == "error" and is_mapping(data) and data.get("error"): + if is_mapping(data) and data.get("error"): message = None error = data.get("error") if is_mapping(error):