Repository navigation
Conversation
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #11872
Summary
A bare
apiBaselikelocalhost:11434(no protocol) or an unresolved template like${{ secrets.MY_KEY }}surfaces as an opaqueTypeError: Invalid URLdeep inside provider code at request time, with no hint of which model or value is at fault. This PR normalizes protocol-less values and validatesapiBaseat construction with an error naming the provider and the bad value. It covers two of the three root causes RomneyDa identified in the issue; the third (thegetMaxStopWords()non-null assertion) is already addressed by #12518 and is deliberately not duplicated here.Root cause
BaseLLM's constructor (core/llm/index.ts) storesapiBasewith only trailing-slash normalization; nothing validates the value, sonew URL(...)fails later wherever a provider first builds a request. Separately, the JSON config path constructs models inside uncaughtPromise.allcalls in core/config/load.ts (chat models, tab-autocomplete, embeddings, reranker), so any single throwing constructor used to reject the entire config load, unlike the YAML path which catches per model (core/config/yaml/loadYaml.ts).Changes
core/llm/index.ts: after trailing-slash normalization, prependhttp://whenapiBasehas no protocol, then validate withnew URL(); on failure throwInvalid apiBase for provider "<name>": "<value>"...including a hint about unresolved secret referencescore/config/load.ts: all four JSON-path construction sites (chat models, tab-autocomplete models, embeddings provider, reranker) now catch constructor errors per model, report them as non-fatalConfigValidationErrors, and continue loading the remaining models — matching the YAML path's behaviorcore/llm/index.test.ts: 4 new tests under "BaseLLM apiBase normalization"What this doesn't change
OpenAI.getMaxStopWords()— the non-null assertion there is fixed by fix(llm): guard getMaxStopWords against undefined apiBase #12518; this PR intentionally does not touch itapiBaseapiBaseGUI placeholders remain falsy and skip validationChecklist
Screen recording or screenshot
Before:
Uncaught TypeError: Invalid URLat request time, no indication of source.After (config load):
Invalid apiBase for provider "ollama": "localhost:11434"...reported as a config error while other models keep loading. Bare hosts likelocalhost:11434now work viahttp://prepending.Tests
cd core && npm test -- llm/index.test.ts— 190/190 passing (186 existing + 4 new). Covers: unresolved template strings throw with provider name and value, bare hosts normalize tohttp://...with trailing slash, undefined apiBase skips validation, well-formed URLs pass through unchanged.cd core && npm run tsc:check— clean.Summary by cubic
Normalize and validate LLM
apiBaseat construction to give clear errors and support bare hosts. JSON config now treats model-construction errors as non-fatal so other models still load.http://whenapiBasehas no protocol and keep trailing slash normalization.apiBaseearly and throw a clear error with provider name and value; includes a hint for unresolved secret references.apiBasenormalization and validation.Written for commit fb45d38. Summary will update on new commits.