Skip to content

fix - passing None as data account should be handled gracefully#44939

Merged
simorenoh merged 7 commits intohotfix/azure-cosmos_4.14.4from
hotfix/azure-cosmos_4.14.6
Feb 4, 2026
Merged

fix - passing None as data account should be handled gracefully#44939
simorenoh merged 7 commits intohotfix/azure-cosmos_4.14.4from
hotfix/azure-cosmos_4.14.6

Conversation

@dibahlfi
Copy link
Member

The _aenter_used flag was introduced in SDK 4.14.2 to optimize the async with pattern. It tracks whether the CosmosClient was initialized using the async context manager (async with CosmosClient(...) as client)

When using async with, the SDK's aenter method fetches the database account before calling force_refresh_on_startup(). The _aenter_used flag tells the SDK "the database account was already fetched, don't fetch it again."

The problem occurs when external code calls force_refresh_on_startup(None) directly: this results in an AttributeError: 'NoneType' object has no attribute '_WritableLocations'

@dibahlfi
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Co-authored-by: Simon Moreno <30335873+simorenoh@users.noreply.github.com>
@dibahlfi
Copy link
Member Author

/azp run python - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

* Remove ApiKey usage

* Add -TestAuth flag to verify Bearer token authentication

* TEMP: Enable TestAuthOnly for pipeline testing

* Remove testing logs

* Additional clean up

* Keep apikey fallback while migrating

* Keep migration to new endpoint

* Keep migration to new endpoint

* Feedback

---------

Co-authored-by: Alitzel Mendez <almend@microsoft.com>
@AlitzelMendez AlitzelMendez requested a review from a team as a code owner January 30, 2026 22:08
@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

dibahlfi commented Feb 2, 2026

/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

Copilot AI added a commit that referenced this pull request Feb 3, 2026
Co-authored-by: simorenoh <30335873+simorenoh@users.noreply.github.com>
@simorenoh simorenoh merged commit 63bbab4 into hotfix/azure-cosmos_4.14.4 Feb 4, 2026
76 checks passed
@simorenoh simorenoh deleted the hotfix/azure-cosmos_4.14.6 branch February 4, 2026 00:56
simorenoh added a commit that referenced this pull request Feb 5, 2026
* Initial plan

* Port None handling changes from PR #44939 to main branch

Co-authored-by: simorenoh <30335873+simorenoh@users.noreply.github.com>

* Update sdk/cosmos/azure-cosmos/CHANGELOG.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @simorenoh

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: simorenoh <30335873+simorenoh@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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