fix(core): filter NULL embeddings from vector index build - #993
Merged
Conversation
Root cause: load_all() returned rows with NULL embedding blobs, which row_to_memory() silently converted to vec![]. When these reached index.build(), the dimension validator rejected them (0 != 768), crashing the server on startup and blocking repair_index. Fix applied at two levels: - SQL level: load_all() now filters 'WHERE embedding IS NOT NULL' - Call sites: lib.rs and maintenance.rs add .filter(|m| !m.embedding.is_empty()) as defense-in-depth guard before index.build() Added regression test: test_load_all_excludes_null_embeddings
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
Merged
ajianaz
added a commit
that referenced
this pull request
Aug 11, 2026
Version bump 0.13.1 → 0.13.2 + CHANGELOG. Changes since v0.13.1: - feat: update check (CLI, MCP, HTTP) (#990) - fix: NULL embeddings crash vector index (#992, #993) - fix: absolute URL in update check redirect (#994) - fix: LongMemEval benchmark threshold false negatives (#995, #996) - chore: branding refresh (#991) Co-authored-by: ajianaz <ajianaz@users.noreply.github.com>
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.
What
Fix crash where NULL embedding rows in SQLite cause
vector_index.build()to fail with dimension mismatch error, blocking server startup andrepair_index.Closes #992.
Why
Memories with
NULLembedding silently convert tovec![]viarow_to_memory(). Whenload_all()returns these rows and they reachindex.build(), the validator rejects them (0 ≠ 768 dims), crashing the server.Production data confirmed: 19 NULL embedding rows out of 596 memories (~3.2%).
Changes
crud.rs—load_all()SQL query: AddedWHERE embedding IS NOT NULLto both namespace-filtered and unfiltered variants. This is the primary fix — NULL rows never enter the build pipeline.lib.rs:731-737— startup index build: Added.filter(|m| !m.embedding.is_empty())guard beforeindex.build(). Also addedif !items.is_empty()check to skip build entirely when all memories have NULL embeddings.maintenance.rs:125-136—repair_index: Same defense-in-depth filter applied.crud.rs— regression test:test_load_all_excludes_null_embeddingsinserts one valid + one NULL embedding row, assertsload_all()returns only the valid row.Testing
cargo fmt --all✅cargo clippy --workspace --all-targets✅ (0 warnings)cargo test --workspace✅ — 480 pass, 0 fail, 26 ignored (was 479, +1 new test)