Skip to content

[Cosmos] query_items with feed_range and continuation bug fix#43700

Merged
simorenoh merged 8 commits intomainfrom
feed_range_bugfix
Oct 31, 2025
Merged

[Cosmos] query_items with feed_range and continuation bug fix#43700
simorenoh merged 8 commits intomainfrom
feed_range_bugfix

Conversation

@simorenoh
Copy link
Copy Markdown
Member

@simorenoh simorenoh commented Oct 30, 2025

This PR fixes a bug with queries using both feed_range and continuation options, where the continuation token for the query was being dragged into an internal SDK call to fetch PK ranges.

This PR also adds additional samples on using feed_ranges along with queries. Follow-up has also been made to work on these more in depth: #43706

@simorenoh simorenoh requested a review from a team as a code owner October 30, 2025 14:00
Copilot AI review requested due to automatic review settings October 30, 2025 14:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where queries using feed_range and continuation options would not work as expected. The fix ensures that when making internal calls to get_overlapping_ranges(), only the necessary partition key range options (specifically containerRID) are passed instead of the entire query options dictionary.

Key Changes

  • Added a new utility function format_pk_range_options() in _base.py to extract only the relevant options for partition key range operations
  • Updated both sync and async query implementations to use this new function before calling get_overlapping_ranges()
  • Updated CHANGELOG to properly categorize the merge support feature and document this bug fix

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sdk/cosmos/azure-cosmos/azure/cosmos/_base.py Added format_pk_range_options() helper function to extract containerRID from query options
sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py Updated to format options before calling get_overlapping_ranges()
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py Updated async version to format options before calling get_overlapping_ranges()
sdk/cosmos/azure-cosmos/CHANGELOG.md Moved merge support entry to correct version and added bug fix entry

Comment thread sdk/cosmos/azure-cosmos/azure/cosmos/_base.py Outdated
Comment thread sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py
@simorenoh
Copy link
Copy Markdown
Member Author

Follow-up tracking issue: #43706

Copy link
Copy Markdown
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

Copy link
Copy Markdown
Member

@tvaron3 tvaron3 left a comment

Choose a reason for hiding this comment

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

LGTM

@simorenoh
Copy link
Copy Markdown
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh
Copy link
Copy Markdown
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh
Copy link
Copy Markdown
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@tvaron3 tvaron3 enabled auto-merge (squash) October 30, 2025 20:41
@tvaron3 tvaron3 disabled auto-merge October 30, 2025 20:42
@simorenoh
Copy link
Copy Markdown
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Member

@tvaron3 tvaron3 left a comment

Choose a reason for hiding this comment

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

LGTM

@simorenoh simorenoh merged commit e4d4839 into main Oct 31, 2025
36 checks passed
@simorenoh simorenoh deleted the feed_range_bugfix branch October 31, 2025 15:08
Copy link
Copy Markdown
Member

@xinlian12 xinlian12 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

JennyPng pushed a commit to JennyPng/azure-sdk-for-python that referenced this pull request Nov 3, 2025
…43700)

* changes, changelog

* Update CHANGELOG.md

* pylint, mypy, tests, samples, comments

* move logic

* Update _read_items_helper.py

* forgot to actually move the logic

* Update _base.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants