Skip to content

fix - fixing global endpoint issue#45200

Merged
simorenoh merged 2 commits intomainfrom
users/dibahl/global-endpoint-routing-fix
Feb 17, 2026
Merged

fix - fixing global endpoint issue#45200
simorenoh merged 2 commits intomainfrom
users/dibahl/global-endpoint-routing-fix

Conversation

@dibahlfi
Copy link
Member

we currently have a bug in the SDK where unavailable endpoints are dropped from the list instead of being appended to the end.

current (buggy) code:

if not regional_endpoints and unavailable_endpoints:
regional_endpoints.extend(unavailable_endpoints)

only adds unavailable endpoints back if ALL are unavailable.

expected(correct) code:
if unavailable_endpoints:
regional_endpoints.extend(unavailable_endpoints)

Copilot AI review requested due to automatic review settings February 15, 2026 01:42
@dibahlfi dibahlfi requested a review from a team as a code owner February 15, 2026 01:42
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 critical bug in the Cosmos DB SDK's location routing logic where unavailable regional endpoints were being dropped from the routing list instead of being appended to the end as fallback options.

Changes:

  • Modified the condition in get_preferred_regional_routing_contexts to always append unavailable endpoints to the routing list (changed from if not regional_endpoints and unavailable_endpoints: to if unavailable_endpoints:)
  • Added comprehensive tests to verify that unavailable endpoints are retained in the routing list and properly ordered (healthy endpoints first, unavailable at the end)
  • Updated comments to clarify the purpose of keeping unavailable endpoints as last-resort fallback options

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sdk/cosmos/azure-cosmos/azure/cosmos/_location_cache.py Fixed the bug by changing the condition to always append unavailable endpoints to the routing list, and updated the comment to explain the rationale
sdk/cosmos/azure-cosmos/tests/test_location_cache.py Added two comprehensive tests: one verifying that unavailable endpoints are not dropped when using excluded_locations, and another verifying proper ordering of healthy vs unavailable endpoints

@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

@simorenoh simorenoh merged commit 9eff742 into main Feb 17, 2026
39 checks passed
@simorenoh simorenoh deleted the users/dibahl/global-endpoint-routing-fix branch February 17, 2026 18:16
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