Skip to content

fix: honoring read_timeout at the cosmos client level#44472

Merged
simorenoh merged 7 commits intomainfrom
users/dibahl/read-timeout-integration
Mar 20, 2026
Merged

fix: honoring read_timeout at the cosmos client level#44472
simorenoh merged 7 commits intomainfrom
users/dibahl/read-timeout-integration

Conversation

@dibahlfi
Copy link
Member

The fix enables client-level read timeout configuration to automatically applies to all queries unless explicitly specified at the request level.

@dibahlfi dibahlfi requested a review from a team as a code owner December 18, 2025 17:15
Copilot AI review requested due to automatic review settings December 18, 2025 17:15
@dibahlfi
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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 implements client-level read timeout configuration for Azure Cosmos DB operations. The fix ensures that when a read timeout is specified at the client level, it automatically applies to all queries and operations unless explicitly overridden at the request level.

Key Changes

  • Added read timeout handling in CosmosClient initialization to propagate client-level timeouts to the connection policy
  • Extended container property getters to pass through read_timeout options from request level
  • Added comprehensive test coverage for client-level, request-level, and policy-level timeout behaviors

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
sdk/cosmos/azure-cosmos/azure/cosmos/cosmos_client.py Added logic to extract and apply client-level read_timeout to ConnectionPolicy
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client.py Added async version of client-level read_timeout handling
sdk/cosmos/azure-cosmos/azure/cosmos/container.py Extended _get_properties_with_options to propagate read_timeout from options
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py Extended async _get_properties_with_options to propagate read_timeout
sdk/cosmos/azure-cosmos/tests/test_crud.py Added three test methods covering request-level override, client-level timeout, and policy-level timeout scenarios
sdk/cosmos/azure-cosmos/tests/test_crud_async.py Added async versions of the three timeout test methods

@allenkim0129
Copy link
Contributor

@dibahlfi Another comment not directly related to this PR. Shouldn't read_timeout and timeout keys in _COMMON_OPTIONS in _base.py ? It looks like they were always set to options in build_options method.

Also, please make both read_timeout and timeout to be constants, so we can avoid using hard-coded strings.

@github-actions
Copy link

Hi @dibahlfi. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days.

@github-actions github-actions bot added the no-recent-activity There has been no recent activity on this issue. label Feb 20, 2026
@github-actions
Copy link

Hi @dibahlfi. Thank you for your contribution. Since there hasn't been recent engagement, we're going to close this out. Feel free to respond with a comment containing /reopen if you'd like to continue working on these changes. Please be sure to use the command to reopen or remove the no-recent-activity label; otherwise, this is likely to be closed again with the next cleanup pass.

@dibahlfi
Copy link
Member Author

dibahlfi commented Mar 4, 2026

/reopen

@github-actions github-actions bot reopened this Mar 4, 2026
@github-actions github-actions bot removed the no-recent-activity There has been no recent activity on this issue. label Mar 4, 2026
@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).

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.

Thank you for addressing comments, and the updated the codes looks good, but I just have some comments on testing.

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.

PR Deep Review — Single Finding

Posting one observation on the docstring type.


⚠️ AI-generated review — may be incorrect. Agree? → resolve the conversation. Disagree? → reply with your reasoning.

@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).

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

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

@dibahlfi
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dibahlfi
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@simorenoh simorenoh merged commit ed10474 into main Mar 20, 2026
39 checks passed
@simorenoh simorenoh deleted the users/dibahl/read-timeout-integration branch March 20, 2026 14:22
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.

5 participants