Skip to content

fix - fixing global endpoint issue#45200

Open
dibahlfi wants to merge 2 commits intomainfrom
users/dibahl/global-endpoint-routing-fix
Open

fix - fixing global endpoint issue#45200
dibahlfi wants to merge 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

Comment on lines +527 to 532
# Always append unavailable endpoints to the end of the list so they can be
# used as a last resort. This ensures that when all healthy endpoints are filtered
# out (e.g., by excluded_locations), the SDK can still fall back to unavailable
# regional endpoints rather than the global endpoint.
if unavailable_endpoints:
regional_endpoints.extend(unavailable_endpoints)
Copy link

Copilot AI Feb 15, 2026

Choose a reason for hiding this comment

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

This bug fix should be documented in the CHANGELOG.md file. Consider adding an entry under a new unreleased version section (e.g., "### 4.15.1 (Unreleased)") with a "#### Bugs Fixed" subsection describing how unavailable endpoints are now properly retained in the routing list as fallback options instead of being dropped entirely.

Copilot uses AI. Check for mistakes.
@dibahlfi
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant