Skip to content

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

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.

4 participants