[Cosmos] Port None handling fix for database_account parameter#44987
Merged
[Cosmos] Port None handling fix for database_account parameter#44987
Conversation
Co-authored-by: simorenoh <30335873+simorenoh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Port new None handling changes to main branch
[Cosmos] Port None handling fix for database_account parameter
Feb 3, 2026
simorenoh
approved these changes
Feb 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Ports the force_refresh_on_startup(None) None-handling hotfix from a released branch into main to prevent crashes during startup/region discovery, and adds targeted regression tests.
Changes:
- Add explicit
database_account is Nonehandling in sync and async global endpoint managers during startup refresh. - Add new sync/async health check tests covering
force_refresh_on_startup(None)and ensuring provided accounts don’t trigger extra fetches. - Make
test_multimasterheader assertions more robust to call ordering by validating counts instead of fixed indices; reduce async flakiness by polling instead of fixed sleep (in one startup failure test).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
sdk/cosmos/azure-cosmos/azure/cosmos/_global_endpoint_manager.py |
Sync startup refresh now fetches the database account when None is passed. |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_global_endpoint_manager_async.py |
Async startup refresh now fetches the database account when None is passed even if _aenter_used=True. |
sdk/cosmos/azure-cosmos/tests/test_health_check.py |
Adds sync regression tests for force_refresh_on_startup(None) and “don’t refetch when account provided”. |
sdk/cosmos/azure-cosmos/tests/test_health_check_async.py |
Adds async regression tests for force_refresh_on_startup(None) and _aenter_used interaction; replaces one fixed sleep with polling. |
sdk/cosmos/azure-cosmos/tests/test_multimaster.py |
Makes tentative-writes header validation resilient to call ordering changes. |
sdk/cosmos/azure-cosmos/CHANGELOG.md |
Adds release note for the None-handling crash fix. |
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_global_endpoint_manager_async.py
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
simorenoh
reviewed
Feb 5, 2026
Member
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
kushagraThapar
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports None handling changes from PR #44939 (hotfix branch) to main. The original fix prevents
AttributeError: 'NoneType' object has no attribute '_WritableLocations'whenforce_refresh_on_startup(None)is called.Core Changes
Sync endpoint manager (
_global_endpoint_manager.py):database_accountin startup pathAsync endpoint manager (
_global_endpoint_manager_async.py):if not self._aenter_used:toif not self._aenter_used or database_account is None:_aenter_used=True(the optimization flag introduced in 4.14.2)Test Changes
test_health_check.py: None handling and optimization validationtest_health_check_async.py: None handling, optimization validation, and_aenter_usedflag interactiontest_multimaster.py: Changed from index-based header assertions to count-based validation (more robust against call order changes)Example of Fixed Scenario
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
scanning-api.github.com/home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.