From d8d5089271ab8b15dfe4bb09e60d6476d41fa417 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 20 Jun 2026 11:00:59 -0400 Subject: [PATCH] refactor(ai_client): narrow 'except:' to specific types in _classify_deepseek/minimax_error (Phase 9 sites 1+2) The bare 'except:' in _classify_deepseek_error (L332) and _classify_minimax_error (L355) was classified as INTERNAL_BROAD_CATCH. Narrowed to 'except (ValueError, AttributeError)' since the only realistic exceptions from exc.response.json() are JSONDecodeError (subclass of ValueError) and AttributeError (if exc.response is None or .json() is missing). --- src/ai_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ai_client.py b/src/ai_client.py index 1a87555b..37c9d758 100644 --- a/src/ai_client.py +++ b/src/ai_client.py @@ -329,7 +329,7 @@ def _classify_deepseek_error(exc: Exception, source: str = "ai_client.deepseek") err_data = exc.response.json() if "error" in err_data: body = str(err_data["error"].get("message", exc.response.text)) else: body = exc.response.text - except: + except (ValueError, AttributeError): body = exc.response.text else: body = str(exc) @@ -352,7 +352,7 @@ def _classify_minimax_error(exc: Exception, source: str = "ai_client.minimax") - err_data = exc.response.json() if "error" in err_data: body = str(err_data["error"].get("message", exc.response.text)) else: body = exc.response.text - except: + except (ValueError, AttributeError): body = exc.response.text else: body = str(exc)