fix: normalize Ollama URLs to handle trailing slashes #6081
+122
−6
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.
This PR fixes issue #6078 where trailing slashes in Ollama API URLs were causing 405 errors and misleading error messages about models not supporting embeddings.
Problem
When users configure their Ollama base URL with a trailing slash (e.g.,
http://localhost:11434/
), the URL concatenation in the code would create double slashes (e.g.,http://localhost:11434//api/embed
), leading to API call failures.Solution
url-normalization
utility that removes trailing slashes from base URLsjoinUrlPath
function to safely join base URLs with pathssrc/api/providers/ollama.ts
src/services/code-index/embedders/ollama.ts
src/api/providers/fetchers/ollama.ts
Testing
This change improves the user experience by preventing confusing errors when configuring Ollama endpoints.
Important
Fixes issue #6078 by normalizing Ollama API URLs to handle trailing slashes, preventing 405 errors.
/
#6078 by normalizing Ollama API URLs to prevent 405 errors due to trailing slashes.normalizeBaseUrl
andjoinUrlPath
inurl-normalization.ts
to handle URL concatenation.src/api/providers/ollama.ts
,src/api/providers/fetchers/ollama.ts
, andsrc/services/code-index/embedders/ollama.ts
to use new utilities.url-normalization.test.ts
to verify URL normalization and joining behavior.This description was created by
for 248a505. You can customize this summary. It will automatically update as commits are pushed.