From 6c7fb4ee449a3ed49a3509691a339016dc1d7266 Mon Sep 17 00:00:00 2001 From: Nathan Esquenazi Date: Thu, 2 Apr 2026 18:06:50 +0000 Subject: [PATCH] fix: NameError on logger in custom endpoint model discovery get_available_models() references 'logger' in the except block of the custom endpoint fetch (added in PR #18), but 'logger' is never imported or defined in api/config.py. When the custom endpoint is unreachable (the normal case -- most users don't have a local LLM), the except handler raises NameError: name 'logger' is not defined, which propagates as a 500 on every GET /api/models request. This broke 7 test_sprint11 tests and caused the model dropdown to fail for all users regardless of whether they have a custom endpoint. Fix: replace logger.debug() with a silent pass -- the exception is expected when no local LLM is configured and needs no logging. Tests: 237 passed, 0 failed. --- api/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/config.py b/api/config.py index 5437cec..3d20459 100644 --- a/api/config.py +++ b/api/config.py @@ -510,8 +510,8 @@ def get_available_models() -> dict: if model_id and model_name: auto_detected_models.append({'id': model_id, 'label': model_name}) detected_providers.add(provider.lower()) - except Exception as e: - logger.debug(f"Failed to fetch models from custom endpoint: {e}") + except Exception: + pass # custom endpoint unreachable or misconfigured -- fail silently # 5. Build model groups if detected_providers: