-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Session Token Manual Override Fix #42965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 manually provided session tokens in options are ignored when client-side session management is disabled. The fix ensures that explicitly provided session tokens take precedence over automatic session management.
- Restructures session token handling logic to prioritize manual overrides
- Adds comprehensive test coverage for the manual session token override scenario
- Updates both synchronous and asynchronous code paths consistently
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
sdk/cosmos/azure-cosmos/azure/cosmos/_base.py | Refactors session token logic to check manual override first, then fallback to automatic session management |
sdk/cosmos/azure-cosmos/tests/test_session.py | Adds test case for manual session token override with disabled client-side session management |
sdk/cosmos/azure-cosmos/tests/test_session_async.py | Adds async version of the manual session token override test case |
/azp run python - cosmos - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR is to fix a bug where if a session token is explicitly provided in options(allowing manual override) it doesn't take effect when client-side session management is disabled.
Fix involve removing the "cosmos_client_connection.session is not None" check from _is_session_token_request method
The _is_session_token_request function is now solely responsible for determining if the type of request is eligible for a session token.
In set_session_token_header, the code first calls the modified _is_session_token_request. If it returns True, the code then enters a block where it checks for a manually provided sessionToken. Because the check for the session object is gone from the initial function, this block is now reachable even when cosmos_client_connection.session is None.
The check for cosmos_client_connection.session still exists in the else block within set_session_token_header. This ensures that the automatic session token logic only runs when client-side session management is actually enabled.