Skip to content

fix(embeddings): check HTTP status before deserializing Ollama embedding response#1702

Open
mvanhorn wants to merge 1 commit intoJetBrains:developfrom
mvanhorn:osc/1499-ollama-embedding-error
Open

fix(embeddings): check HTTP status before deserializing Ollama embedding response#1702
mvanhorn wants to merge 1 commit intoJetBrains:developfrom
mvanhorn:osc/1499-ollama-embedding-error

Conversation

@mvanhorn
Copy link
Copy Markdown

When Ollama returns an error response (e.g., model not loaded, server unavailable), OllamaClient.embed() attempts to deserialize the error body as EmbeddingResponseDTO, causing a JsonDecodingException. The user sees a serialization stack trace instead of the actual error message from Ollama.

This adds an HTTP status check before deserialization, matching the pattern already used by executeImpl() at line 206 in the same file. On non-success status codes, a LLMClientException is thrown with the HTTP status and Ollama's error body, giving users a clear error message like:

Embedding request failed (HTTP 404): {"error":"model 'nomic-embed-text' not found"}

instead of a JsonDecodingException stack trace.

Fixes #1499

This contribution was developed with AI assistance (Claude Code).

…ing response

When Ollama returns an error (e.g., model not loaded), the response body
doesn't match EmbeddingResponseDTO, causing a JsonDecodingException. This
adds the same status check used by the chat method, throwing a clear
LLMClientException with the HTTP status and error body instead.

Fixes JetBrains#1499
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.

Ollama Embedding Failures Result in Deserialization Exception

1 participant