Skip to content

session token data optimization#44484

Merged
tvaron3 merged 9 commits intomainfrom
users/dibahl/session-token-data-optimization
Mar 16, 2026
Merged

session token data optimization#44484
tvaron3 merged 9 commits intomainfrom
users/dibahl/session-token-data-optimization

Conversation

@dibahlfi
Copy link
Member

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.

Copilot AI review requested due to automatic review settings December 19, 2025 04:00
@dibahlfi dibahlfi requested a review from a team as a code owner December 19, 2025 04:00
Copy link
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 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_header call 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

Copy link
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 but please run live tests

@simorenoh
Copy link
Member

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dibahlfi
Copy link
Member Author

dibahlfi commented Mar 6, 2026

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@github-actions
Copy link

github-actions bot commented Mar 7, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-cosmos

Copy link
Contributor

@allenkim0129 allenkim0129 left a comment

Choose a reason for hiding this comment

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

LGTM

@dibahlfi
Copy link
Member Author

dibahlfi commented Mar 9, 2026

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@tvaron3 tvaron3 merged commit fe6046b into main Mar 16, 2026
22 checks passed
@tvaron3 tvaron3 deleted the users/dibahl/session-token-data-optimization branch March 16, 2026 20:41
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.

6 participants