Skip to content

fix(providers): stop reporting an absent Ollama as an error - #6387

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/ollama-hosted-polling
Aug 7, 2026
Merged

fix(providers): stop reporting an absent Ollama as an error#6387
waleedlatif1 merged 2 commits into
stagingfrom
fix/ollama-hosted-polling

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

OllamaModelsAPI is the single largest error stream in the app: 10,068 in 14 days, and every one is the same line — Unable to connect to http://localhost:11434. OLLAMA_URL is unset in production, so the route falls back to a hardcoded loopback default and dials it on every poll.

Its siblings already handle this correctly, and produce zero errors over the same window:

Route Absent-service handling Errors / 14d
vLLM logger.info('VLLM_BASE_URL not configured') 0
LiteLLM logger.info('LITELLM_BASE_URL not configured') 0
Ollama none — always dials the default 10,068

Changes

  • An unreachable Ollama logs at info, not error. It is optional; a deployment that runs none refuses the connection on every poll, which is an expected state, not a failure of this route. This is the half that helps self-hosters
  • The hosted platform skips the probe, since it has no local runtime and the loopback default cannot answer — but only when OLLAMA_URL is unset. An explicit URL states intent and is still honoured, even on hosted
  • isOllamaUrlConfigured() sits beside getOllamaUrl() so OLLAMA_URL keeps a single owner, rather than the route reaching around it to read the same variable

The response is { models: [] } on every non-success path, exactly as before — the same value a blacklisted provider already returns.

Nothing changes for self-hosters

All four permutations are exercised as tests:

Deployment Probes Ollama? vs. before
Self-hosted, localhost default, no configuration yes identical
Self-hosted, explicit OLLAMA_URL yes identical
Hosted, no configuration skipped the fix
Hosted, explicit OLLAMA_URL yes honoured

Verified preconditions rather than assumed them:

  • OLLAMA_URL is declared in the env schema (z.string().url().optional()), so the configured-check reads a real value
  • isHosted is forceHosted || hostname === 'sim.ai' || *.sim.ai, and forceHosted requires !isProd — a self-hosted production deployment can never satisfy it
  • providers/utils already imports env-flags, so the new import adds no dependency weight
  • The Ollama provider (providers/ollama/index.ts, the execution path) is untouched; this only affects the model-listing route

Type of Change

  • Bug fix

Testing

5 tests. Both halves verified red on their own revert — removing the gate fails the hosted case, restoring logger.error fails the unreachable case. The first version of the level test passed either way (it only asserted the response body), so it now asserts the level itself.

app/api/providers 50 passing / 5 files; wider sweep 1,593 passing. Typecheck, biome, and check:api-validation clean. One unrelated suite fails in the worktree from a tailwind v4/v3 resolution artifact — it fails with my changes stashed and passes on the main checkout (13/13).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Ollama is optional and its URL falls back to a loopback default, so a deployment
that runs none refuses the probe on every poll — 10,068 of these in 14 days, the
single largest error stream in the app, all of them the same expected condition.

Report it the way the vLLM and LiteLLM routes already report an unconfigured
base URL, and skip the probe entirely on the hosted platform, which has no local
runtime to reach. An explicit OLLAMA_URL is still honoured everywhere, so a
self-hosted deployment behaves exactly as before — including the localhost
default that requires no configuration.
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 7, 2026 7:45pm

Request Review

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Logging and optional early-return for the Ollama model-list route only; API responses stay { models: [] } on failure paths and self-hosted probe behavior is preserved.

Overview
Stops the Ollama models API from flooding production logs when no Ollama is present. The route used to always hit the loopback default and log errors on every poll; vLLM/LiteLLM already treat missing optional backends as info and return { models: [] }.

Hosted: When isHosted and OLLAMA_URL is unset, the route skips the fetch entirely (loopback cannot work there). An explicit OLLAMA_URL still probes.

Self-hosted: Behavior unchanged for successful probes; connection failures now log at info (Ollama service is not reachable) instead of error, while bad 2xx bodies still log error (Ollama returned a response this route cannot read).

Adds isOllamaUrlConfigured() next to getOllamaUrl() in urls.ts, and a new route.test.ts covering hosted skip, explicit URL on hosted, self-hosted default, unreachable vs malformed responses, blacklist, and non-2xx.

Reviewed by Cursor Bugbot for commit ee8aa7f. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This follow-up cleanly separates an absent Ollama service from malformed successful responses while avoiding unnecessary hosted-platform probes.

  • Skips the default loopback probe on hosted deployments unless OLLAMA_URL is explicitly configured.
  • Logs connection failures at info level while preserving warning-level non-2xx and error-level unreadable-response diagnostics.
  • Adds coverage for hosted and self-hosted configurations, connection failures, invalid responses, and blacklist behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/app/api/providers/ollama/models/route.ts Splits connection, HTTP-status, and response-decoding outcomes so only an absent optional Ollama service is treated as informational.
apps/sim/app/api/providers/ollama/models/route.test.ts Adds focused tests for deployment modes, explicit configuration, logging levels, response validation, and provider blacklisting.
apps/sim/lib/core/utils/urls.ts Adds a centralized helper distinguishing an explicit Ollama URL from the loopback fallback.

Reviews (2): Last reviewed commit: "fix(providers): keep an unreadable Ollam..." | Re-trigger Greptile

Comment thread apps/sim/app/api/providers/ollama/models/route.ts Outdated
Comment thread apps/sim/app/api/providers/ollama/models/route.ts Outdated
…chable path

The single catch covered the connection, the JSON read, and the schema parse, so a
server that answered but answered wrongly was filed as 'no Ollama here'. Scope the
quiet path to the connection itself and report an unusable response as the fault
it is.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ee8aa7f. Configure here.

@waleedlatif1
waleedlatif1 merged commit de5fcf9 into staging Aug 7, 2026
30 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/ollama-hosted-polling branch August 7, 2026 19:52
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.

1 participant