Skip to content

fix(settings): don't send a stale base URL to a fixed-endpoint AI provider - #458

Merged
parthrohit22 merged 1 commit into
devfrom
fix/ai-provider-stale-base-url
Sep 11, 2026
Merged

parthrohit22 merged 1 commit into
devfrom
fix/ai-provider-stale-base-url

Conversation

@parthrohit22

Copy link
Copy Markdown
Collaborator

Found from a live report: with Ollama saved, selecting Google Gemini answers

AI provider destination is not permitted.

and there is nothing on screen to correct.

Cause

useSettings loads baseUrl from the saved configuration and never clears it when the provider changes:

const chooseProvider = useCallback((nextProvider: AiProvider) => {
  setProvider(nextProvider);
  setModel(capabilityByProvider.get(nextProvider)?.defaultModel ?? '');
  // baseUrl untouched

So the Ollama URL is still sent. The backend rejects any base URL on a fixed destination:

if config.provider in FIXED_PROVIDER_DESTINATIONS:
    if config.base_url is not None:
        raise _deny()

Gemini, OpenAI, Anthropic and OpenRouter all have fixed endpoints and therefore render no base URL field — so the value causing the denial cannot be seen or cleared. There is no sequence of UI actions that recovers, because reloading re-reads the saved Ollama config and puts the URL straight back. Anyone who has ever saved Ollama is locked out of every hosted provider.

The backend is right to refuse; the denial is deliberately non-specific, which is correct for an egress policy and also why the message could not point at the cause.

Fix

Selecting a provider that takes no base URL clears it, and baseUrlForRequest() omits the field entirely for such a provider regardless of what state holds — belt and braces, since the field is invisible in exactly the case that breaks. A provider that does require one is unaffected.

Tests

Two, both confirmed failing without the fix — the first reproduces the reported sequence exactly (expected 'http://localhost:11434' to be ''):

  • a saved Ollama base URL is not carried into a fixed-endpoint provider, and neither testConfig nor saveConfig receives the field
  • a provider that requires a base URL still sends it

464 frontend tests, tsc and eslint clean.

Not changed

The egress policy itself. Denying a base URL on a fixed destination is correct, and making the message specific would leak policy detail — the bug was the client sending a value the user could not see.

…vider

Saving Ollama and then selecting Google Gemini answered "AI provider
destination is not permitted." with nothing on screen to correct.

The base URL is loaded into form state from the saved configuration and was
never cleared when the provider changed, so the Ollama URL was still being
sent. A fixed-destination provider rejects any base URL at all
(`ai_egress.validate_config`: `if config.base_url is not None: raise
_deny()`), so the request was denied -- and because those providers show no
base URL field, the offending value was invisible. There was no sequence of
UI actions that could recover: reloading re-reads the saved Ollama config and
puts the URL straight back.

Selecting a provider that does not take a base URL now clears it, and the
save and test requests omit the field entirely for such a provider whatever
the state happens to hold. A provider that does require one is unaffected.
@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
partha-frontend Ready Ready Preview Sep 11, 2026 7:10pm UTC

@parthrohit22
parthrohit22 merged commit 6198154 into dev Sep 11, 2026
14 checks passed
@parthrohit22
parthrohit22 deleted the fix/ai-provider-stale-base-url branch September 11, 2026 19:29
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