From dce2405e50ab334d3080bc23363b718593b4cf9b Mon Sep 17 00:00:00 2001 From: Suriyakumarvijayanayagam Date: Fri, 14 Aug 2026 18:29:16 +0530 Subject: [PATCH] Stop /api/system/status 500ing when Ollama is switched off _ensure_client() returns None - not False - when USE_OLLAMA is false, because it returns before it ever probes. SystemStatusOut.ollama_connected is typed bool, so pydantic rejected the None and the endpoint answered 500 on exactly the configuration this deployment runs. Found by smoke-testing the live host: every other read route answered 200 and this one alone was a server error, which read like a database problem and was not one. "Ollama is off" now reports as ollama_connected: false. Co-Authored-By: Claude Opus 5 --- app/api/routers/system.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/api/routers/system.py b/app/api/routers/system.py index 8df2187..323db7e 100644 --- a/app/api/routers/system.py +++ b/app/api/routers/system.py @@ -87,7 +87,13 @@ def get_system_status() -> SystemStatusOut: except Exception: pass - ollama_ok = _ensure_client() + # bool(), because _ensure_client() has three return values, not two: True and + # False when Ollama is enabled and reachable/unreachable, and None when + # USE_OLLAMA is false - it returns before it ever probes. ollama_connected is + # typed bool, so that None failed response_model validation and turned the + # whole endpoint into a 500 on exactly the configuration this deployment + # runs (USE_OLLAMA=false). "Ollama is switched off" is not a server error. + ollama_ok = bool(_ensure_client()) dist_ok = FRONTEND_DIST.exists() and (FRONTEND_DIST / "index.html").exists() return SystemStatusOut(