Skip to content

fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default #1165

Closed

Description

@dan-petty

Rule (owner, 2026-10-04)

No client falls back to an unconfigured service URL. A service's URL comes from the configuration, or from a connection the CLI opened itself (a port-forward it started). When neither exists, the command stops with an error naming the setting to set. It never guesses localhost:<port>. Ollama stays a supported provider when it is configured. This applies to every service the CLI talks to, not only AI.

Where defaults live (owner, 2026-10-04): suggested values, such as the gateway, Qdrant and Jaeger URLs, live in config.example.yaml, not in code. devops k8s deploy-stack writes the URLs of what it deployed into the configuration when they are not set yet. If nothing is configured and nothing is running, the command returns an error naming the setting.

Problem

AI callers fall back to a hard-coded http://localhost:11434 when no Ollama URL is set, even when the configuration names a working provider (ai.provider: gateway with its URL). Ollama stays supported when it is configured. The bug is an invalid implicit default used in place of the valid configuration.

Evidence (owner's iteration runs, 2026-10-04): all three devops ai benchmark --type embedding runs failed with ConnectError to localhost:11434, using the chat model, then exited 0 and were saved as normal runs. The causes:

  • ai/benchmark/embedding_runner.py:250 falls back to ["http://localhost:11434"], and :279 switches the provider to Ollama when the URL contains :11434 or ollama;
  • commands/benchmark.py:316 defaults the embedding model to settings.ai.model, the chat model.

The fallback appears at 17 sites in src, and the same URL is defined three times (config/constants.py:538 CONST_URL_OLLAMA_LOCALHOST, ai/models/ollama.py:31 DEFAULT_OLLAMA_BASE_URL, config/defaults.py:385 DEFAULT_OLLAMA_HOST):

  • ai/benchmark/runner.py:202 and ai/benchmark/embedding_runner.py:250
  • ai/rag/embeddings.py:489; ai/rag/indexer.py:581-582
  • ai/client/ollama.py:182; ai/client/unified.py:282-284
  • ai/review/pipeline.py:218,230; ai/review/runner.py:149,161,171
  • ai/providers/ollama.py:55

Acceptance criteria

  • One resolver gives every AI caller its endpoint from the configured provider:
    • with the gateway configured, that is the gateway URL and its model aliases;
    • with Ollama configured, the configured Ollama URLs.
  • No caller falls back to localhost:11434, or to any URL the configuration does not name. With no usable configuration, a caller stops with an error naming the setting to fix.
  • One constant names Ollama's default port, used only where a person or the config wizard picks Ollama explicitly. The three duplicate URL constants are gone.
  • The provider is chosen by configuration, never by a substring of the URL (embedding_runner.py:279; library-first: feat(ci): hand-rolled URL and address parsing fails devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107).
  • The embedding benchmark defaults to the configured embedding model (the gateway's embedding alias), not ai.model. A run where every request failed exits non-zero and is not saved as a run. This overlaps feat(ai): embeddings through the llm gateway, with embedding model evaluation #481, whichever lands first.
  • Tests: with a gateway-only config, a fake transport sees every benchmark, RAG, review and client call go to the gateway URL, and a socket guard proves nothing tries localhost:11434. Tests run offline, each under 1 s.
  • The same rule holds for the other services. Hard-coded fallbacks found on 2026-10-04 are http://localhost:6333 (Qdrant, 5 sites) and http://localhost:16686 (Jaeger, 6 sites), from rg -n '"https?://(localhost|127\.0\.0\.1)' src. URLs built from a port-forward the CLI opened itself (http://localhost:{ports[...]}) and a server's own bind address stay.
  • config.example.yaml holds the suggested URL for each service, and no code default repeats it. A test checks that every service URL setting has an example value and no code default.
  • devops k8s deploy-stack sets each service URL it deployed (gateway, Qdrant, observability) in the configuration when that setting is empty. It never overwrites a set value, and it reports what it set. Its --dry-run lists these config writes and makes no request (feat(cli): reachable --dry-run previews for delegated commands #412).
  • With nothing configured, devops ai test, devops ai benchmark --type embedding, devops rag query and devops review path each exit non-zero with an error naming the setting. Test: an empty config, and a socket guard proving no connection was tried.
  • A guard keeps it that way: an ast-grep rule, in the style of feat(ci): hand-rolled URL and address parsing fails devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107's enforcement, rejects a string literal http(s)://localhost or 127.0.0.1 used as a fallback value in src, with an allowlist for the port-forward and bind cases.

Notes

Update 2026-10-08: refinement

The search also finds the gateway, Portkey, vLLM, OTLP, Loki and Pyroscope defaults (config/defaults.py:89-93, :220-222), used as field defaults (config/settings.py:472, :475), and get_ollama_urls' fallback (:521-532). #992 and #1000 now leave these to this item; whichever lands first removes the fallback, and the others do not bring it back.

Activity

  1. added
    type/bug
    scope/ai
    priority/p2-medium
    on Oct 4, 2026
  2. changed the title [-]fix(ai): ai callers take their endpoint from the configured provider and never fall back to localhost:11434[/-] [+]fix(config): service clients use only configured urls and never fall back to an unconfigured localhost default[/+] on Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p2-mediumscope/aitype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions