Repository navigation
fix(atlas): add missing isDeleted filter in _convertFilter and guard empty objectIds in mutations - #367
Conversation
📝 WalkthroughWalkthroughEarly-return guards were added to Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@nodes/test/test_atlas_isdeleted_filter.py`:
- Around line 53-66: The __init__ in the filter class uses redundant
kwargs.get(..., None) calls; update the constructor to call kwargs.get('nodeId')
etc. (remove the explicit None defaults) for attributes nodeId, isTable,
tableIds, parent, permissions, objectIds, isDeleted, chunkIds, minChunkId,
maxChunkId while leaving the explicit defaults for limit and offset
(kwargs.get('limit', 25), kwargs.get('offset', 0)) unchanged; ensure assignments
like self.nodeId = kwargs.get('nodeId') and similarly for the other listed
attributes.
- Around line 147-148: The two nested context managers should be combined into a
single with statement to satisfy Ruff SIM117: replace the nested with
patch.object(atlas_mod.Config, 'getNodeConfig', return_value=mock_config) and
with patch.object(atlas_mod, 'MongoClient') as MockClient: with one combined
context manager using a comma (i.e., with patch.object(atlas_mod.Config,
'getNodeConfig', return_value=mock_config), patch.object(atlas_mod,
'MongoClient') as MockClient:) so the test uses a single with block while
preserving MockClient and the mocked getNodeConfig behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6b311701-1473-4e36-88b7-bb04b9ae4dcd
📒 Files selected for processing (2)
nodes/src/nodes/atlas/atlas.pynodes/test/test_atlas_isdeleted_filter.py
|
Evidence hardening pass for this PR. Reproduction (before)
Validation (after)
CI Evidence
Why this is distinct
|
kwit75
left a comment
There was a problem hiding this comment.
LGTM. Adds isDeleted filter + guards empty objectIds in atlas mutations.
stepmikhaylov
left a comment
There was a problem hiding this comment.
Thanks for this contribution.
One small request before merging: could you please move nodes/test/test_atlas_isdeleted_filter.py to nodes/test/atlas/test_isdeleted_filter.py so the test layout matches our project conventions?
- Add meta.isDeleted=false to Mongo filters when DocFilter does not request deleted docs, matching qdrant/weaviate/milvus behavior - Short-circuit remove/markDeleted/markActive when objectIds is empty - Add unit tests for _convertFilter and mutation guards Made-with: Cursor
b269ad8 to
ef959f4
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@nodes/test/atlas/test_isdeleted_filter.py`:
- Around line 29-43: The test currently injects globals into sys.modules using
sys.modules.setdefault (via mock_depends_mod and multiple pymongo/numpy
entries), which can leak mocks across tests; replace these top-level setdefault
calls with a scoped patch by using unittest.mock.patch.dict on sys.modules
around the import/load of the atlas module (or inside a test fixture) so the
temporary module entries are applied only during atlas module loading and
automatically reverted; specifically, encapsulate the creation of
mock_depends_mod and the sys.modules entries for 'depends', 'pymongo',
'pymongo.collection', 'pymongo.database', 'pymongo.errors',
'pymongo.operations', and 'numpy' in a patch.dict context/fixture used when
importing the code that references those modules (e.g., where atlas is
imported/initialized) to avoid global pollution.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: c9a3cda8-2b17-4e2e-bd3a-c478ace95a15
📒 Files selected for processing (3)
nodes/src/nodes/atlas/atlas.pynodes/test/atlas/__init__.pynodes/test/atlas/test_isdeleted_filter.py
…empty objectIds in mutations (rocketride-org#367) * fix(atlas): honor soft-delete filter and guard empty object id mutations - Add meta.isDeleted=false to Mongo filters when DocFilter does not request deleted docs, matching qdrant/weaviate/milvus behavior - Short-circuit remove/markDeleted/markActive when objectIds is empty - Add unit tests for _convertFilter and mutation guards Made-with: Cursor * refactor: move atlas test to nodes/test/atlas per project conventions
Summary
isDeletedhandling to Atlas MongoDB_convertFilter, aligning it with every other vector store (Qdrant, Weaviate, Milvus, Pinecone, Postgres, Chroma, Astra_DB, Elasticsearch)remove,markDeleted,markActiveto short-circuit onobjectIds=[]Bug
The Atlas MongoDB vector store node (
nodes/src/nodes/atlas/atlas.py) has two bugs:Missing
isDeletedfilter in_convertFilter— Every other vector store handlesDocFilter.isDeletedin its_convertFiltermethod, but Atlas does not. This causes:get()results. Users who soft-delete documents viamarkDeleted()will still see those documents in keyword search, semantic search, andget()queries._checkCollectionExists()in the base class — The base classDocumentStoreBase._checkCollectionExists()(line 421 ofstore.py) setsfilter.isDeleted = Trueto locate the schema control document. WithoutisDeletedfiltering in_convertFilter, the queryget(filter)ignores theisDeleted=Trueflag entirely, returning all docs withobjectId='schema'regardless of deletion status. While this may not immediately break (if only one such document exists), it violates the contract and can return incorrect results if stale control documents exist.Missing empty-list guards in
remove,markDeleted,markActive— When called with an emptyobjectIdslist, MongoDB's{'$in': []}matches nothing, which is safe but sends an unnecessary round-trip to the server. This is a minor defensive fix for consistency with other nodes.Steps to Reproduce
Filter output comparison (before vs after fix):
Root Cause
In
_convertFilter(line 396–431 ofatlas.py), the method converts everyDocFilterfield to a MongoDB query condition exceptisDeleted. The field is simply never checked.Compare with the identical pattern implemented in:
qdrant.pyline 215-216):if docFilter.isDeleted is None or not docFilter.isDeleted: must.append(FieldCondition(key='meta.isDeleted', match=MatchValue(value=False)))weaviate.pyline 226-227):if docFilter.isDeleted is None or not docFilter.isDeleted: must.append(Filter.by_property('isDeleted').equal(False))milvus.pyline 208-209):if docFilter.isDeleted is None or not docFilter.isDeleted: must_conditions.append("meta['isDeleted'] == False")Atlas is the only vector store missing this filter.
Fix
nodes/src/nodes/atlas/atlas.py:Added
isDeletedhandling to_convertFilterafter theobjectIdsblock:Added empty-list early returns to
remove,markDeleted, andmarkActive:Why This Works
isDeletedisNone(default) orFalse: the filter adds{'meta.isDeleted': False}, excluding soft-deleted documents from results. This is the standard behavior across all other vector stores.isDeletedisTrue: no filter is added, so all documents (including deleted ones) are returned. This is exactly what the base class needs in_checkCollectionExists()to find the schema control document (which is stored withisDeleted=True).Testing / Validation
12 new unit tests in
nodes/test/test_atlas_isdeleted_filter.py:test_default_filter_excludes_deletedDocFilter()→{'meta.isDeleted': False}test_explicit_false_excludes_deletedDocFilter(isDeleted=False)→{'meta.isDeleted': False}test_explicit_true_includes_allDocFilter(isDeleted=True)→ nometa.isDeletedkeytest_combined_with_nodeIdnodeIdandisDeletedfilters coexisttest_combined_with_objectIdsobjectIdsandisDeletedfilters coexisttest_isdeleted_true_with_objectIdsisDeleted=True+objectIds→ only objectIds filtertest_remove_noop_on_empty_listremove([])→ no MongoDB calltest_markDeleted_noop_on_empty_listmarkDeleted([])→ no MongoDB calltest_markActive_noop_on_empty_listmarkActive([])→ no MongoDB calltest_remove_calls_mongodb_with_idsremove(['id-1'])→ correctdelete_manycalltest_markDeleted_calls_mongodb_with_idsmarkDeleted(['id-1'])→ correctupdate_manycalltest_markActive_calls_mongodb_with_idsmarkActive(['id-1'])→ correctupdate_manycall./builder testrequires a full native C++ build chain (CMake, vcpkg, JDK 17) which is not feasible in this environment. The Python unit tests and contract tests cover the changed code paths.Type
Checklist
nodes/test/test_atlas_isdeleted_filter.py— 12 tests)./builder testpasses (blocked by native C++ build requirement; Python tests and contract tests pass)fix(atlas): ...)Related Issues
None filed — fix identified by parity review with other vector store implementations.
#frontier-tower-hackathon
Impact
This aligns Atlas filtering with other stores so soft-deleted documents do not leak into normal query results.
CI Evidence
Summary by CodeRabbit
Bug Fixes
Tests