Skip to content

[Backport 2.6] fix: correct parameter name typos in QueryIterator causing partition filter bypass (#3324)#3330

Merged
sre-ci-robot merged 1 commit intomilvus-io:2.6from
pymilvus-bot:backport-3324-to-2.6-1774236627-32344
Mar 23, 2026
Merged

[Backport 2.6] fix: correct parameter name typos in QueryIterator causing partition filter bypass (#3324)#3330
sre-ci-robot merged 1 commit intomilvus-io:2.6from
pymilvus-bot:backport-3324-to-2.6-1774236627-32344

Conversation

@pymilvus-bot
Copy link
Collaborator

Manual backport of #3324 to 2.6.

…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>
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: pymilvus-bot, 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

@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.93%. Comparing base (0243181) to head (fa00c63).
⚠️ Report is 1 commits behind head on 2.6.

Additional details and impacted files
@@           Coverage Diff           @@
##              2.6    #3330   +/-   ##
=======================================
  Coverage   89.93%   89.93%           
=======================================
  Files          64       64           
  Lines       13348    13348           
=======================================
  Hits        12004    12004           
  Misses       1344     1344           

☔ 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 23, 2026
@sre-ci-robot sre-ci-robot merged commit 90251c7 into milvus-io:2.6 Mar 23, 2026
13 checks passed
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