fix: correct parameter name typos in QueryIterator causing partition filter bypass#3324
Conversation
|
Welcome @alohaha22! It looks like this is your first PR to milvus-io/pymilvus 🎉 |
2e2f930 to
bd3beb0
Compare
bd3beb0 to
a5da0a3
Compare
`__seek_to_offset` passed `output_field` (singular) and `partition_name` (singular) to `conn.query()`, which expects `output_fields` and `partition_names` (plural). The misspelled names fell into **kwargs and were silently ignored, causing the seek phase to scan all partitions instead of the target one, producing an incorrect PK cursor when both `partition_names` and `offset` are used. `__setup_ts_by_request` had the same typo but since it only sets up mvccTs (a global timestamp), changed to pass empty lists instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: alohaha22 <shawn.work1229@outlook.com>
a5da0a3 to
940548b
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3324 +/- ##
=======================================
Coverage 90.04% 90.04%
=======================================
Files 64 64
Lines 13638 13638
=======================================
Hits 12281 12281
Misses 1357 1357 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alohaha22, XuanYang-cn The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
❌ Backport Failed (cc @XuanYang-cn) |
1 similar comment
|
❌ Backport Failed (cc @XuanYang-cn) |
|
✅ Backport Created (cc @XuanYang-cn) |
…filter bypass (milvus-io#3324) ## Summary - Fix typo in `QueryIterator.__seek_to_offset` and `__setup_ts_by_request`: `output_field` → `output_fields`, `partition_name` → `partition_names` - The singular parameter names didn't match `grpc_handler.query()`'s signature, so they fell into `**kwargs` and were silently ignored - This caused the seek phase to scan **all partitions** instead of the target one when both `partition_names` and `offset` are specified, producing an incorrect PK cursor ## Bug Details When `query_iterator` is called with both `partition_names` and `offset`: 1. The seek phase queries all partitions instead of the specified one (because `partition_names=None` on the server side short-circuits the partition filter) 2. The PK cursor is set based on global data, not the target partition's data 3. `next()` correctly filters by partition (it already uses plural names), but the cursor position is wrong 4. The returned row count does not match expectations For example, with `partition_names=["part_b"]` and `offset=50` on a partition with 100 rows (PKs 100–199): - **Before fix**: returns 100 rows (expected 50) - **After fix**: returns 50 rows (correct) ## Changes - `pymilvus/orm/iterator.py`: Fix 4 parameter names (2 in `__seek_to_offset`, 2 in `__setup_ts_by_request`) - `tests/orm/test_iterator.py`: Add `TestQueryIteratorPartitionNamesPassthrough` with 4 tests verifying correct parameter names are passed through to `conn.query()` ## Test plan - [x] New tests fail before the fix (confirmed via TDD red phase) - [x] New tests pass after the fix - [x] Full iterator test suite passes (136/136) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: alohaha22 <shawn.work1229@outlook.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> (cherry picked from commit 4a02330) Signed-off-by: pymilvus-bot <pymilvus-bot@users.noreply.github.com>
…sing partition filter bypass (#3324) (#3330) Manual backport of #3324 to `2.6`. Signed-off-by: alohaha22 <shawn.work1229@outlook.com> Signed-off-by: pymilvus-bot <pymilvus-bot@users.noreply.github.com> Co-authored-by: alohaha22 <shawn.work1229@outlook.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
QueryIterator.__seek_to_offsetand__setup_ts_by_request:output_field→output_fields,partition_name→partition_namesgrpc_handler.query()'s signature, so they fell into**kwargsand were silently ignoredpartition_namesandoffsetare specified, producing an incorrect PK cursorBug Details
When
query_iteratoris called with bothpartition_namesandoffset:partition_names=Noneon the server side short-circuits the partition filter)next()correctly filters by partition (it already uses plural names), but the cursor position is wrongFor example, with
partition_names=["part_b"]andoffset=50on a partition with 100 rows (PKs 100–199):Changes
pymilvus/orm/iterator.py: Fix 4 parameter names (2 in__seek_to_offset, 2 in__setup_ts_by_request)tests/orm/test_iterator.py: AddTestQueryIteratorPartitionNamesPassthroughwith 4 tests verifying correct parameter names are passed through toconn.query()Test plan
🤖 Generated with Claude Code