Skip to content

Improve Ollama error handling and add LLM healthcheck#269

Open
sanvishukla wants to merge 1 commit intofireform-core:mainfrom
sanvishukla:feature/268-improve-ollama-errors
Open

Improve Ollama error handling and add LLM healthcheck#269
sanvishukla wants to merge 1 commit intofireform-core:mainfrom
sanvishukla:feature/268-improve-ollama-errors

Conversation

@sanvishukla
Copy link

@sanvishukla sanvishukla commented Mar 16, 2026

Summary:

This PR adds clearer errors when the Ollama backend is unreachable and introduces a /health/llm endpoint to quickly verify LLM availability, improving setup and debugging for new users.
closes #268

Changes:

src/llm.py: more detailed ConnectionError message (includes URL, OLLAMA_HOST, and troubleshooting steps).
api/errors/base.py: new LLMUnavailableError (HTTP 503).
src/file_manipulator.py: wrap ConnectionError from LLM in LLMUnavailableError.
api/main.py: register AppError handler and add GET /health/llm using Ollama’s /api/tags.
api/errors/handlers.py: reuse existing handler for the new error.

Testing:

With Ollama stopped: /health/llm and /forms/fill return 503 with a JSON error instead of a traceback.
image
image

With ollama serve running and mistral pulled: /health/llm returns {"status": "ok"} and /forms/fill still succeeds and generates a filled PDF.
image
image

@utkarshqz
Copy link

Hi @sanvishukla , I appreciate the focus on backend reliability! I submitted PR #239 on March 13 to address these specific Ollama connection timeouts and hardening. It might be worth consolidating our work to ensure we don't have redundant error-handling logic in the main loop.

@sanvishukla
Copy link
Author

Hey @utkarshqz, thanks for pointing this out, I went through your PR.

From what I understand, your changes focus on improving visibility during extraction, progress logging + handling slow requests, while this PR is more focused on cases where the LLM backend isn’t reachable at all, like when Ollama isn’t running, misconfigured, or the model isn’t pulled.

The idea here was to make those failures clearer (returning a 503 instead of a traceback) and also add a lightweight /health/llm endpoint to quickly verify setup without running the full pipeline. I think they address slightly different failure modes and could work well together, especially combining runtime logging with clearer error handling and health checks.

Happy to refactor or align things if needed to avoid any duplication!

@utkarshqz
Copy link

Thanks @sanvishukla! Good to be on the same page. I'm finishing up some work on the batching routes, and having a reliable /health check from your end would be great for the frontend UI. Let's make sure our endpoint naming is consistent so the integration is smooth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Ollama connection errors and add LLM health endpoint

2 participants