Skip to content

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

Merged
AaronBarnes07 merged 4 commits into
mainfrom
DM-4708-cosmosdb
Sep 9, 2026
Merged

DM-4708: add CosmosDbConnectionConfig for Azure Cosmos DB#46
AaronBarnes07 merged 4 commits into
mainfrom
DM-4708-cosmosdb

Conversation

@AaronBarnes07

@AaronBarnes07 AaronBarnes07 commented Sep 5, 2026

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.

Related

This work spans four repositories:

Merge request Ticket What it carries
datamasque!3711 DM-4707 The connection type: agent dialect, connection form, docs.
thisdatamasque-python#46 DM-4708 CosmosDbConnectionConfig, so the client can create these connections.
datamasque-automation!1232 DM-4708 The MongoDB AIT suite running against Cosmos DB as a pooled engine.
ui-testing!257 DM-4707 Playwright coverage for the connection form.

Merge in this order. datamasque-python 1.3.0 has to be on PyPI before the AIT branch can swap
its TestPyPI pin, and the UI tests need a DataMasque build carrying the connection type:

  1. datamasque-python#46, then release 1.3.0 to PyPI
  2. datamasque!3711
  3. datamasque-automation!1232
  4. ui-testing!257

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
The class described itself as "for MongoDB", which names the API rather than the product.
The port now defaults to 10255, so a caller no longer has to know it.
@AaronBarnes07
AaronBarnes07 marked this pull request as ready for review September 7, 2026 03:15
Cosmos DB rejects retryable inserts, not every write, so masking still runs with them on
and it is the run-history insert that is lost.
@AaronBarnes07
AaronBarnes07 merged commit bb3ebf0 into main Sep 9, 2026
9 checks passed
@AaronBarnes07
AaronBarnes07 deleted the DM-4708-cosmosdb branch September 9, 2026 01:33
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.

3 participants