Skip to content

fix: correct parameter name typos in QueryIterator causing partition filter bypass#3324

Merged
sre-ci-robot merged 1 commit intomilvus-io:masterfrom
alohaha22:fix/query-iterator-partition-names-typo
Mar 20, 2026
Merged

fix: correct parameter name typos in QueryIterator causing partition filter bypass#3324
sre-ci-robot merged 1 commit intomilvus-io:masterfrom
alohaha22:fix/query-iterator-partition-names-typo

Conversation

@alohaha22
Copy link
Contributor

Summary

  • Fix typo in QueryIterator.__seek_to_offset and __setup_ts_by_request: output_fieldoutput_fields, partition_namepartition_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

  • New tests fail before the fix (confirmed via TDD red phase)
  • New tests pass after the fix
  • Full iterator test suite passes (136/136)

🤖 Generated with Claude Code

@sre-ci-robot
Copy link

Welcome @alohaha22! It looks like this is your first PR to milvus-io/pymilvus 🎉

@mergify mergify bot added the needs-dco label Mar 19, 2026
@alohaha22 alohaha22 force-pushed the fix/query-iterator-partition-names-typo branch from 2e2f930 to bd3beb0 Compare March 20, 2026 02:59
@mergify mergify bot added dco-passed and removed needs-dco labels Mar 20, 2026
@alohaha22 alohaha22 force-pushed the fix/query-iterator-partition-names-typo branch from bd3beb0 to a5da0a3 Compare March 20, 2026 03:47
`__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>
@alohaha22 alohaha22 force-pushed the fix/query-iterator-partition-names-typo branch from a5da0a3 to 940548b Compare March 20, 2026 03:53
@codecov
Copy link

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.04%. Comparing base (9c29ad1) to head (940548b).
⚠️ Report is 3 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mergify mergify bot added the ci-passed label Mar 20, 2026
Copy link
Contributor

@XuanYang-cn XuanYang-cn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@sre-ci-robot
Copy link

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot sre-ci-robot merged commit 4a02330 into milvus-io:master Mar 20, 2026
12 of 13 checks passed
@pymilvus-bot
Copy link
Collaborator

Backport Failed
Hi @alohaha22, failed to push backport branch for 2.6.

(cc @XuanYang-cn)

1 similar comment
@pymilvus-bot
Copy link
Collaborator

Backport Failed
Hi @alohaha22, failed to push backport branch for 2.6.

(cc @XuanYang-cn)

@pymilvus-bot
Copy link
Collaborator

Backport Created
Hi @alohaha22, Backport PR for 2.6 has been created: #3330

(cc @XuanYang-cn)

pymilvus-bot pushed a commit to pymilvus-bot/pymilvus that referenced this pull request Mar 23, 2026
…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>
sre-ci-robot pushed a commit that referenced this pull request Mar 23, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants