fix(settings): don't send a stale base URL to a fixed-endpoint AI provider - #458
Merged
Merged
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found from a live report: with Ollama saved, selecting Google Gemini answers
and there is nothing on screen to correct.
Cause
useSettingsloadsbaseUrlfrom the saved configuration and never clears it when the provider changes:So the Ollama URL is still sent. The backend rejects any base URL on a fixed destination:
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 ''):testConfignorsaveConfigreceives the field464 frontend tests,
tscandeslintclean.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.