Fix cryptic SQLite error when remote embedder is unreachable - #10
Closed
krisajenkins wants to merge 1 commit into
Closed
krisajenkins wants to merge 1 commit into
krisajenkins wants to merge 1 commit into
Conversation
When the remote embedder (Ollama) returned an HTTP error (e.g. model not
found, server down), the zero-vector fallback in embed_batch silently
swallowed the error. This meant the probe embed in main.rs "succeeded"
without discovering the embedding dimension, leaving it at 0. The 0 was
then passed to SQLite's vec0 table constructor as `float[0]`, producing
the unhelpful error:
vec0 constructor error: could not parse vector column
'embedding float[0] distance_metric=cosine'
Three fixes:
1. Propagate errors from embed_batch when embedding_dim is still unknown.
The zero-vector fallback is only safe after we've discovered the real
dimension from at least one successful embed call.
2. Read HTTP error response bodies and extract the server's error message
(supports OpenAI-style, Ollama, and plain text formats). Previously
ureq's http_status_as_error discarded the body, so errors just said
"http status: 404". Now they say e.g.:
Embeddings API returned HTTP 404: model "mxbai-embed-large" not
found, try pulling it first
3. Defensive check in main.rs: bail with a clear message if embedding_dim
is still 0 after the probe, pointing at the model name and URL.
Owner
|
@copilot fix merge errors and run cargo fmt |
martintrojer
added a commit
that referenced
this pull request
Mar 16, 2026
- Check HTTP status codes from remote embedder and extract human-readable error messages from OpenAI/Ollama-style JSON error responses - Validate embedding dimension is non-zero after probe - Propagate errors early when embedding_dim is unknown (can't create valid zero vectors without knowing the dimension) Co-authored-by: Kris Jenkins <krisajenkins@users.noreply.github.com>
Owner
|
Merged in ef9038a — thanks @krisajenkins! |
martintrojer
added a commit
that referenced
this pull request
Mar 16, 2026
- query_context_length: explicitly check HTTP status after http_status_as_error(false) change, instead of relying on JSON parse failure for error responses - Remove unreachable dim=0 check in main.rs — the embed_batch early-propagation fix means the probe always errors before returning a zero dimension - Add 5 tests for extract_error_message (OpenAI, simple, Ollama, plain text, truncation)
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.
Summary
embed_batchwhenembedding_dimis still unknown, instead of silently falling back to a zero vector with a guessed dimensionhttp_status_as_errordiscarded the body, so errors just said"http status: 404"initialize_embedder: bail with a clear message ifembedding_dimis 0 after the probeBefore:
After:
Test plan
vecgrep --reindexwith a valid remote embedder config (Ollama + mxbai-embed-large) succeedsvecgrep --reindexwith an unavailable model gives a clear error pointing at the model/URLvecgrep --reindexwith Ollama not running gives a clear connection errorcargo testpasses (same pre-existing failures only)cargo clippy -- -D warningsis clean