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 <noreply@anthropic.com>
This commit is contained in:
Suriyakumarvijayanayagam
2026-08-14 18:29:16 +05:30
parent c17e1c7e13
commit dce2405e50

View File

@@ -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(