Repository navigation
fix(preflight): stop the probe from creating the collection with Chroma's default EF - #253
Conversation
…ma's default EF On a fresh data_dir the preflight child ran get_or_create_collection() without an embedding function, so ChromaDB persisted its `default` EF. The server then opened the collection with FastEmbed and ChromaDB raised "Embedding function conflict: new: fastembed-... vs persisted: default". v4.10.0 removed the destructive recovery that used to hide this, so every fresh install and every new Docker volume failed to start. - The probe reads the collection with get_collection() and reports "missing" when it does not exist yet. - _safe_get_collection() recreates the collection the old probe left behind, only when it is empty and bound to the default EF. A collection with data is never dropped; the error is raised as before. Closes #248 Closes #252 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 51 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Read-only preflight probe mcp_server/preflight.py, tests/test_preflight.py, CHANGELOG.md |
The probe reports missing when the collection does not exist and does not create it. A subprocess test checks the missing and existing collection cases. |
Empty collection recovery mcp_server/server.py, tests/test_storage_safety.py |
Startup retries collection access after removing an empty collection bound to Chroma’s default embedding function. Tests verify that an empty collection is replaced and a populated collection is preserved. |
Priority:
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: hohlas
Merge Risk: 
Minimal · up to d78cd
-
The change stops the preflight probe from creating a default-embedding collection, so fresh installs should start. It deletes only empty default-embedding collections and keeps populated ones. A remaining race needs unsupported concurrent multi-writer startup, so merge risk is minimal.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
The PR meets the coding requirements in [
#248] and [#252].mcp_server/preflight.pynow callsget_collection(..., embedding_function=None)and reportsmissingafterNotFoundError, so a fresh data directory does not create a default-EF collection.mcp_server/server.pyopens the production collection withself.embed_fn. Recovery drops and recreates only an empty collection whose persisted embedding function isdefault. Collections with data remain intact, and the original open error includesExisting index preserved. Tests cover the real read-only probe, empty default-EF recovery, and preservation of populated default-EF collections.
Full details: Out of Scope Changes check
-
Explanation
The changes stay within the linked issue scope. The preflight change prevents the reported startup failure. The server recovery change supports migration from the stale empty collection without discarding indexed data. The added tests verify the issue behavior and storage safety. The changelog entry documents the fix.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 64.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 4 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
…e default-EF leftover The real-probe test only seeded a collection bound to Chroma's default EF. Existing users have collections written through FastEmbedEmbeddings, persisted as a legacy EF, and three probe failures would quarantine them. Seed that case with data, then the empty default-EF leftover. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Applying
The production code is identical in all three runs, and this PR touches neither the query cache nor FTS5. Its only runtime change sits in the startup error path. A different random subset of sub-100 µs benchmarks crosses ±10% on each run. |
…ma's default EF (#253) On a fresh data_dir the preflight child ran get_or_create_collection() without an embedding function, so ChromaDB persisted its `default` EF. The server then opened the collection with FastEmbed and ChromaDB raised "Embedding function conflict: new: fastembed-... vs persisted: default". v4.10.0 removed the destructive recovery that used to hide this, so every fresh install and every new Docker volume failed to start. - The probe reads the collection with get_collection() and reports "missing" when it does not exist yet. - _safe_get_collection() recreates the collection the old probe left behind, only when it is empty and bound to the default EF. A collection with data is never dropped; the error is raised as before. - Tests run the real probe child against a fresh data_dir, a production FastEmbed collection with data and the empty default-EF leftover. Closes #248 Closes #252
Summary
Fresh installs and new data directories fail to start on v4.10.0 and v4.11.0 with
Embedding function conflict: new: fastembed-… vs persisted: default(#248, #252).Root cause: since v3.9.0 the preflight probe ran
get_or_create_collection(name)without an embedding function. On a freshdata_dirit created the collection, and ChromaDB persisted itsdefaultEF. Up to v4.9.x,_safe_get_collection()deleted and recreated the collection on any EF conflict, which hid the problem. v4.10.0 (#234) correctly stopped deleting on open errors, and that exposed it: every fresh install, and every new Docker volume, now crashes at startup.Closes #248
Closes #252
Type of change
What changed
mcp_server/preflight.py: the probe opens the collection withget_collection(..., embedding_function=None)and printsmissingonNotFoundError. It never creates anything.mcp_server/server.py: when opening fails,_safe_get_collection()calls_drop_empty_default_ef_collection(), which drops the collection only if it is empty and its persisted EF is ChromaDB'sdefault— the leftover of the old probe — and then recreates it with FastEmbed. A collection holding data is never dropped, and the original error is still raised ("Existing index preserved").missingwith nothing created; existing collection → counted), plus two storage-safety tests (the empty leftover is recreated and survives the next start; a default-EF collection with data is never dropped).Why
Reproduced end to end on unmodified master: on a fresh
KNOWLEDGE_RAG_DIRthe real probe leavesknowledge_basewith{'type': 'known', 'name': 'default'}, and opening it the way the server does fails with the exact error from both issues. Same result on chromadb 1.4.0 (minimum supported) and 1.5.9.collection.modify(configuration={"embedding_function": ...})cannot rebind the EF in place (ChromaDB requiresis_legacy()on the EF), so recreating the empty leftover is the smallest fix. Limiting it to empty collections keeps the v4.10.0 guarantee that data is never discarded on open errors.The probe test runs the real child instead of mocking it: the probe must never fail on a healthy index, because three failures quarantine the index.
7 Pillars Quality Gate
1. Security
eval,exec,subprocess shell=True,pickle.loadson untrusted input, or arbitrary deserialization2. Stability
xfailto make the PR pass3. Memory leak
4. Versatility
5. Scalability
Performance impact: N/A — no hot-path change. The new code runs only when opening the collection fails at startup.
6. Versioning
pyproject.toml,mcp_server/__init__.py, andnpm/package.json(no bump in this PR)### UnreleasedinCHANGELOG.mdcheck_api_surface.py --checkOK)7. Quality
ruff checkpassesruff format --checkpassesinterrogate90.6%)vultureclean)Migration / Breaking changes
N/A. Installs that already hit the error start normally after upgrading: the empty leftover collection is recreated once, with a
[RECOVERY]line on stderr.Test plan
pytest tests/passed locally — 1267 passed, 1 skipped (Windows 11, Python 3.12, chromadb 1.5.9)ruff,ruff format,bandit,interrogate,vulture,check_api_surface,check_version_sync,check_changelog,check_test_count,git diff --check— cleanKNOWLEDGE_RAG_DIR→ real preflight probe → server-style open, on chromadb 1.4.0 and 1.5.9. Before the fix it fails with the reported error; after it the probe printsmissing, creates nothing, and the open succeeds.Documentation
README.md(if user-facing) — not neededdocs/(if applicable) — not needed### UnreleasedinCHANGELOG.mdReviewer checklist
By submitting this PR I confirm I read CONTRIBUTING.md and agree to the Code of Conduct.
Summary by CodeRabbit


Confidence Score: 5/5
The PR appears safe to merge, with the previous coverage gap addressed and no new blocking issues found.Summary
The PR stops the startup probe from creating collections and recovers empty collections left with ChromaDB's default embedding function.
Reviews (2) · Last reviewed commit: "test(preflight): probe a production Fast..." · Reviewed by Greptile