From 913f610db5ab46ef5df9c537693aea07defb01c9 Mon Sep 17 00:00:00 2001 From: cybermaggedon Date: Fri, 15 May 2026 13:35:04 +0100 Subject: [PATCH] Ensure retry exception is properly raised (#926) --- .../trustgraph/model/text_completion/openai/llm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/trustgraph-flow/trustgraph/model/text_completion/openai/llm.py b/trustgraph-flow/trustgraph/model/text_completion/openai/llm.py index df1bfdd1..c8ab9c36 100755 --- a/trustgraph-flow/trustgraph/model/text_completion/openai/llm.py +++ b/trustgraph-flow/trustgraph/model/text_completion/openai/llm.py @@ -111,7 +111,7 @@ class Processor(LlmService): code = body.get('error', {}).get('code') if code in ('insufficient_quota', 'invalid_api_key', 'account_deactivated'): raise RuntimeError(f"OpenAI unrecoverable error: {code} - {body['error'].get('message', '')}") - except Exception: + except (ValueError, KeyError, TypeError, AttributeError): pass # Leave rate limit retries to the base handler raise TooManyRequests() @@ -204,7 +204,7 @@ class Processor(LlmService): if code in ('insufficient_quota', 'invalid_api_key', 'account_deactivated'): logger.warning(f"Hit unrecoverable rate limit error during streaming: {code}") raise RuntimeError(f"OpenAI unrecoverable error: {code} - {body['error'].get('message', '')}") - except Exception: + except (ValueError, KeyError, TypeError, AttributeError): pass logger.warning("Hit rate limit during streaming") raise TooManyRequests()