Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a session token optimization bug where compound session tokens (containing tokens for all partitions) were being sent for single-partition feed range queries. The fix ensures that when querying with a specific feed range, only the relevant partition's session token is sent, reducing unnecessary token data in requests.
Key Changes
- Added
set_session_token_headercall within the feed range loop to set partition-specific session tokens - Added comprehensive tests for both sync and async clients to verify single partition tokens are sent instead of compound tokens
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py | Adds call to set_session_token_header for specific partition within feed range loop |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py | Adds call to set_session_token_header for specific partition within feed range loop (async version) |
| sdk/cosmos/azure-cosmos/tests/test_session.py | Adds test to verify single partition tokens are sent for feed range queries |
| sdk/cosmos/azure-cosmos/tests/test_session_async.py | Adds async test to verify single partition tokens are sent for feed range queries |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py
Outdated
Show resolved
Hide resolved
tvaron3
approved these changes
Dec 19, 2025
Member
tvaron3
left a comment
There was a problem hiding this comment.
LGTM but please run live tests
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py
Show resolved
Hide resolved
Member
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
simorenoh
approved these changes
Dec 19, 2025
…//github.com/Azure/azure-sdk-for-python into users/dibahl/session-token-data-optimization
Member
Author
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
tvaron3
reviewed
Mar 9, 2026
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_global_endpoint_manager_async.py
Show resolved
Hide resolved
Member
Author
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
simorenoh
approved these changes
Mar 10, 2026
simorenoh
approved these changes
Mar 16, 2026
tvaron3
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed a bug where a compound session token (containing multiple partition tokens) was sent for single-partition feed range queries. Now, only the relevant partition's session token is sent when querying with a specific feed range reducing unnecessary token data in requests.