Description
If Ollama crashes or Groq rate-limits mid-request, ask_ollama() in backend/llm/client.py raises a RuntimeError. This exception is not caught in the /api/chat route in backend/app.py, so it propagates as an unhandled 500 Internal Server Error with a raw Python traceback.
Reproduction
- Start the backend
- Stop Ollama (
pkill ollama) or exhaust Groq rate limits
- Send any chat message
- Observe: raw 500 error, no user-friendly message
Impact
Users see a confusing error with no indication of what went wrong or how to fix it. The frontend displays a generic failure with no actionable guidance.
Fix Needed
Wrap the answer_question() call in /api/chat with a try/except RuntimeError block:
try:
result = answer_question(question, session_id, language)
except RuntimeError as e:
raise HTTPException(status_code=503, detail=str(e))
This returns a clean 503 Service Unavailable with the specific LLM error message (e.g. "Cannot connect to Ollama. Is 'ollama serve' running?").
Files Affected
backend/app.py — /api/chat route
Description
If Ollama crashes or Groq rate-limits mid-request,
ask_ollama()inbackend/llm/client.pyraises aRuntimeError. This exception is not caught in the/api/chatroute inbackend/app.py, so it propagates as an unhandled 500 Internal Server Error with a raw Python traceback.Reproduction
pkill ollama) or exhaust Groq rate limitsImpact
Users see a confusing error with no indication of what went wrong or how to fix it. The frontend displays a generic failure with no actionable guidance.
Fix Needed
Wrap the
answer_question()call in/api/chatwith atry/except RuntimeErrorblock:This returns a clean
503 Service Unavailablewith the specific LLM error message (e.g. "Cannot connect to Ollama. Is 'ollama serve' running?").Files Affected
backend/app.py—/api/chatroute