fix(chroma): version incompatibility fails silently + NoneType 'delete' crash#1452
Conversation
…e' crash Fixes rocketride-org#1405 `list_collections()`'s return shape differs across chromadb client versions: newer clients (>=0.6) return a list of collection name strings, older clients (<0.6) return a list of Collection objects exposing `.name`. `_doesCollectionExist` compared `self.collection` (a str) directly against the raw list, which only worked for the string-returning shape -- against an older server it silently evaluated to "collection does not exist" even when it did, and a raw client/server incompatibility during `list_collections()` (e.g. `KeyError('_type')`) propagated as an opaque error with no indication of the real cause. Downstream, `flush()` called `self.collectionObj.delete(...)` / `.upsert(...)` without checking whether `collectionObj` had actually been resolved, so a prior silent failure surfaced later as an opaque `AttributeError: 'NoneType' object has no attribute 'delete'` instead of an actionable message -- appearing to the user as "0 done, 1 error" during ingestion with no clue why. Fix: - Normalize `list_collections()` results to a set of names regardless of whether the client returns strings or Collection-like objects. - Wrap `list_collections()` failures with a message naming the host/port and pointing at a likely version mismatch. - Fail fast in `flush()` with a clear, actionable error when the collection was never resolved, instead of letting it crash deep inside a per-chunk write. Added regression tests covering both the version-shape bug and the flush() guard; verified they fail against the pre-fix code and pass after the fix.
🤖 Internal: Discord sync markerAuto-managed by the Discord notification workflow. Stores the linked Discord message ID. Do not edit or delete. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughModified ChangesChroma version compatibility
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant Store
participant ChromaClient
Caller->>Store: addChunks(chunks, checkCollection)
Store->>Store: _doesCollectionExist()
Store->>ChromaClient: list_collections()
alt list_collections fails
ChromaClient-->>Store: raises error
Store-->>Caller: raise descriptive version-mismatch error
else success
ChromaClient-->>Store: names or objects
Store->>Store: normalize to set of names
Store-->>Caller: True/False
end
Store->>Store: flush()
alt collectionObj is None
Store-->>Caller: raise "not initialized" error
else
Store->>ChromaClient: delete/upsert
end
Related issues: Suggested labels: bug, chroma, tests Suggested reviewers: rocketride-org/backend-maintainers 🐰 A rabbit checked the collections twice, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Fixes rocketride-org#1405 -- Chroma version incompatibility fails silently + NoneType 'delete' crash. See PR rocketride-org#1452: rocketride-org#1452
Fixes #1405
list_collections()'s return shape differs across chromadb client versions: newer clients (>=0.6) return a list of collection name strings, older clients (<0.6) return a list of Collection objects exposing.name._doesCollectionExistcomparedself.collection(a str) directly against the raw list, which only worked for the string-returning shape -- against an older server (e.g. Chroma 0.5.18) it silently evaluated to "collection does not exist" even when it did, and a raw client/server incompatibility duringlist_collections()(e.g.KeyError('_type')) propagated as an opaque error with no indication of the real cause.Downstream,
flush()calledself.collectionObj.delete(...)/.upsert(...)without checking whethercollectionObjhad actually been resolved, so a prior silent failure surfaced later as an opaqueAttributeError: 'NoneType' object has no attribute 'delete'instead of an actionable message -- appearing to the user as "0 done, 1 error" during ingestion with no clue why, and downstream chat systems then answering from training data instead of indexed content.Fix
list_collections()results to a set of names regardless of whether the client returns strings or Collection-like objects.list_collections()failures with a message naming the host/port and pointing at a likely version mismatch, instead of letting a rawKeyErrorpropagate.flush()with a clear, actionable error when the collection was never resolved, instead of letting it crash deep inside a per-chunk write.A hard client/server version gate was intentionally left out of scope -- that's a call for maintainers who know the actual supported compatibility matrix. This PR fixes the underlying behavioral defect and makes failures surface clearly, which resolves the reported crash and silent-failure symptoms directly.
Testing
nodes/test/chroma/test_collection_version_compat.py(7 new tests) covering both the version-shape bug and theflush()guard.assert False is Trueon the version-shape test; raw'_type'and'NoneType' object has no attribute 'delete'messages on the other two), and pass after the fix.ruff check/ruff format --diffclean on all changed files.Summary by CodeRabbit
NoneType/attribute error by failing fast with actionable feedback.