Skip to content

DM-4708: add CosmosDbConnectionConfig for Azure Cosmos DB - #46

Draft
AaronBarnes07 wants to merge 2 commits into
mainfrom
DM-4708-cosmosdb
Draft

DM-4708: add CosmosDbConnectionConfig for Azure Cosmos DB#46
AaronBarnes07 wants to merge 2 commits into
mainfrom
DM-4708-cosmosdb

Conversation

@AaronBarnes07

Copy link
Copy Markdown
Collaborator

DM-4708: add CosmosDbConnectionConfig for Azure Cosmos DB for MongoDB.

Cosmos DB's MongoDB API is wire-compatible, so the config reuses MongoConnectionConfig and differs only by db_type/database_type and two defaults: tls on, because Cosmos DB accepts nothing else, and retry_writes off, because Cosmos DB rejects retryable writes.

Needed by the DataMasque AIT suite, which creates Cosmos connections through this client (datamasque-automation!1232), and pairs with the server-side connection type (datamasque!3711).

Issues found along the way

The inherited serializer dropped the values it was asked to send. MongoConnectionConfig._serialize prunes tls when falsy and retry_writes when truthy, which encodes MongoDB's server-side defaults. Cosmos DB inverts both, so CosmosDbConnectionConfig(..., tls=False) or (..., retry_writes=True) had the key dropped and the server applied the opposite of what was asked, silently. Pruning now compares against the concrete class's default, which is the default the server applies for that connection type.

DatabaseConnectionConfig did not steer users at the new class. It raises a "use X instead" error for dynamodb, snowflake, mongodb and databricks, but not for cosmosdb — nor for the pre-existing documentdb. Both are added.

HISTORY.rst named the wrong server version. The connection type ships in 3.26.17, not 3.26.18.

Before this is released

The AIT suite currently pins 1.3.0.dev1 from TestPyPI, and the db2i runner installs its pin from public PyPI, so 1.3.0 needs a real release before datamasque-automation!1232 can merge.

Testing

520 tests passing; ruff check, ruff format --check and mypy clean.

Cosmos DB's MongoDB API is wire-compatible, so the config reuses
MongoConnectionConfig and differs only by db_type and two defaults: TLS on,
because Cosmos only accepts TLS, and retryable writes off, because Cosmos
rejects them.

Needed by the AIT framework, which builds its DataMasque connection payloads
through this client.
The Mongo serializer pruned `tls` when falsy and `retry_writes` when truthy, which
encodes MongoDB's server-side defaults. Cosmos DB inverts both, so a caller asking for
`tls=False` or `retry_writes=True` had the key dropped and the server applied the
opposite. Pruning now compares against the concrete class's default, which is the
default the server applies for that connection type.

`DatabaseConnectionConfig` also now steers documentdb and cosmosdb at their own classes,
as it already did for the other special engines, and the release requires 3.26.17 rather
than 3.26.18.
@AaronBarnes07 AaronBarnes07 self-assigned this Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants