PYTHON-5808 Drop support for MongoDB 4.2 - #2892
Conversation
Bump minimum supported server version to MongoDB 4.4 (wire version 9). Remove dead code paths that only applied to wire version < 8 servers, including the legacy OP_GET_MORE protocol, the use_command dispatch mechanism, and the from_command response field.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Update post-42-*.json SDAM error fixtures and test_wire_version to use wire version 9 (MongoDB 4.4), which is now the minimum supported version.
This reverts commit b2b6c5b.
Skip SDAM error spec tests whose mock servers report wire versions below the new minimum (9 / MongoDB 4.4), and update the test_wire_version assertion to use MIN_SUPPORTED_WIRE_VERSION.
Update mock servers in mockupdb tests to use MIN_SUPPORTED_WIRE_VERSION instead of the hardcoded wire version 8 (MongoDB 4.2).
Fix shlex-splitting bug in coverage command that broke multi-word marker expressions (e.g. 'not default_async and default') when GREEN_FRAMEWORK is set, by building subprocess args as a list instead of a shell string. Switch enterprise auth setup to use SASL_HOST_BUILD and PRINCIPAL_BUILD secrets so GSSAPI and SASL tests connect to a MongoDB 4.4+ server instead of the legacy 4.2 LDAP test server.
The KEYTAB_BASE64 keytab only contains entries for the old PRINCIPAL (ldaptest.10gen.cc). Switch to KEYTAB_BASE64_BUILD which matches PRINCIPAL_BUILD (ldaptest.build.10gen.cc).
|
This is currently blocked on getting appropriate credentials for the new 4.4 enterprise test server |
Use the original KEYTAB_BASE64 secret for kinit.
Point kinit at ldaptest.build.10gen.cc (the MongoDB 4.4+ LDAP server) by writing a krb5.conf with the appropriate realm configuration instead of using an empty file.
…THON-5808 # Conflicts: # .evergreen/generated_configs/tasks.yml # .evergreen/scripts/generate_config_utils.py # doc/changelog.rst # pymongo/asynchronous/mongo_client.py # pymongo/asynchronous/server.py # pymongo/message.py # pymongo/synchronous/mongo_client.py # pymongo/synchronous/server.py
Upstream removed the use_cmd parameter from _Query.get_message(). Update the call site in cursor_base.py to match the new signature.
There was a problem hiding this comment.
Pull request overview
Raises PyMongo’s minimum supported MongoDB version to 4.4 and removes obsolete compatibility paths.
Changes:
- Sets minimum wire version to 9 and simplifies runtime logic.
- Removes obsolete version-gated tests and regenerates CI configurations.
- Updates compatibility documentation and adds unrelated CI bootstrap changes.
Reviewed changes
Copilot reviewed 80 out of 80 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
README.md |
Updates supported server versions. |
doc/changelog.rst |
Records dropping MongoDB 4.2. |
pymongo/common.py |
Raises minimum server and wire versions. |
pymongo/message.py |
Removes legacy getMore protocol handling. |
pymongo/operations.py |
Removes obsolete 4.2 requirements. |
pymongo/response.py |
Removes legacy response-origin state. |
pymongo/encryption_options.py |
Updates encryption requirements. |
pymongo/asynchronous/aggregation.py |
Always applies supported read concern. |
pymongo/asynchronous/auth.py |
Removes legacy authentication branching. |
pymongo/asynchronous/auth_aws.py |
Removes redundant version validation. |
pymongo/asynchronous/bulk.py |
Removes obsolete hint compatibility tracking. |
pymongo/asynchronous/change_stream.py |
Uses server resumability labels exclusively. |
pymongo/asynchronous/collection.py |
Removes pre-4.4 option checks. |
pymongo/asynchronous/cursor.py |
Updates min/max hint documentation. |
pymongo/asynchronous/cursor_base.py |
Removes legacy cursor response plumbing. |
pymongo/asynchronous/mongo_client.py |
Simplifies retryable-write labeling. |
pymongo/asynchronous/pool.py |
Updates handshake compatibility comment. |
pymongo/asynchronous/topology.py |
Removes obsolete pool-clearing behavior. |
pymongo/synchronous/aggregation.py |
Sync counterpart for read concern. |
pymongo/synchronous/auth.py |
Sync authentication simplification. |
pymongo/synchronous/auth_aws.py |
Sync AWS validation cleanup. |
pymongo/synchronous/bulk.py |
Sync hint compatibility cleanup. |
pymongo/synchronous/change_stream.py |
Sync resumability simplification. |
pymongo/synchronous/collection.py |
Sync option-check cleanup. |
pymongo/synchronous/cursor.py |
Sync hint documentation update. |
pymongo/synchronous/cursor_base.py |
Sync cursor plumbing cleanup. |
pymongo/synchronous/mongo_client.py |
Sync retryable-write simplification. |
pymongo/synchronous/pool.py |
Sync handshake comment update. |
pymongo/synchronous/topology.py |
Sync topology behavior cleanup. |
test/__init__.py |
Simplifies test capability detection. |
test/asynchronous/__init__.py |
Async test capability detection. |
test/test_bulk.py |
Removes obsolete version gates. |
test/test_change_stream.py |
Removes obsolete change-stream gates. |
test/test_collection.py |
Removes legacy index/exhaust cases. |
test/test_connections_survive_primary_stepdown_spec.py |
Removes version decorators. |
test/test_csot.py |
Removes pre-4.0 workaround. |
test/test_cursor.py |
Retains only MongoDB 4.4 behavior. |
test/test_custom_types.py |
Removes change-stream version gates. |
test/test_database.py |
Removes legacy aggregation branch. |
test/test_discovery_and_monitoring.py |
Skips unsupported-wire scenarios. |
test/test_encryption.py |
Removes obsolete encryption gate. |
test/test_examples.py |
Removes MongoDB 4.4 decorator. |
test/test_message.py |
Updates getMore command tests. |
test/test_monitoring.py |
Removes deprecated find scenarios. |
test/test_on_demand_csfle.py |
Removes obsolete CSFLE gates. |
test/test_read_concern.py |
Assumes supported $out behavior. |
test/test_retryable_reads.py |
Removes minimum-version decorators. |
test/test_retryable_writes.py |
Removes retry-label version gates. |
test/test_sdam_monitoring_spec.py |
Removes pre-4.4 SDAM test. |
test/test_topology.py |
Uses shared minimum wire version. |
test/test_transactions.py |
Removes legacy transaction branches. |
test/asynchronous/test_bulk.py |
Async bulk test cleanup. |
test/asynchronous/test_change_stream.py |
Async change-stream gate cleanup. |
test/asynchronous/test_collection.py |
Async index/exhaust cleanup. |
test/asynchronous/test_connections_survive_primary_stepdown_spec.py |
Async decorator cleanup. |
test/asynchronous/test_csot.py |
Async workaround removal. |
test/asynchronous/test_cursor.py |
Async MongoDB 4.4 behavior. |
test/asynchronous/test_custom_types.py |
Async custom-type gate cleanup. |
test/asynchronous/test_database.py |
Async aggregation branch cleanup. |
test/asynchronous/test_discovery_and_monitoring.py |
Async unsupported-wire skipping. |
test/asynchronous/test_encryption.py |
Async encryption gate cleanup. |
test/asynchronous/test_examples.py |
Async example decorator cleanup. |
test/asynchronous/test_monitoring.py |
Async deprecated find cleanup. |
test/asynchronous/test_on_demand_csfle.py |
Async CSFLE gate cleanup. |
test/asynchronous/test_read_concern.py |
Async $out behavior update. |
test/asynchronous/test_retryable_reads.py |
Async retryable-read gate cleanup. |
test/asynchronous/test_retryable_writes.py |
Async retry-label gate cleanup. |
test/asynchronous/test_sdam_monitoring_spec.py |
Async pre-4.4 SDAM removal. |
test/asynchronous/test_transactions.py |
Async transaction cleanup. |
test/mockupdb/test_cursor_namespace.py |
Uses current minimum wire version. |
test/mockupdb/test_op_msg.py |
Updates mock server wire version. |
test/mockupdb/test_standalone_shard.py |
Updates standalone mock wire version. |
.evergreen/scripts/generate_config.py |
Removes MongoDB 4.2 exclusions. |
.evergreen/scripts/generate_config_utils.py |
Removes 4.2 from version matrix. |
.evergreen/generated_configs/tasks.yml |
Regenerates task matrix. |
.evergreen/generated_configs/variants.yml |
Removes MongoDB 4.2 variant. |
.evergreen/scripts/install-dependencies.sh |
Adds Python bootstrap workaround. |
.evergreen/scripts/setup-dev-env.sh |
Reloads generated environment settings. |
.evergreen/scripts/setup-uv-python.sh |
Adds missing-toolchain fallback. |
.evergreen/scripts/setup_tests.py |
Exports an additional SASL variable. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Some images (e.g. the DEVPROD-19149 Windows image) ship without a Python toolchain. | ||
| # A python3 may still be on PATH there (the mingw one that comes with chocolatey) that | ||
| # runs but cannot bootstrap pip, so probe for one that can actually create a virtual | ||
| # environment. We probe python3 specifically because that is the name | ||
| # drivers-evergreen-tools' find_python3 falls back to, and it only checks that the | ||
| # interpreter runs - not that it can build the venv it then goes on to need. |
There was a problem hiding this comment.
This logic can be removed, it was needed for the temporary host. I plan to open a ticket to use ensure_uv from drivers-evergreen-tools directly instead of duplicating the uv/python discovery here.
PYTHON-5808
Changes in this PR
Drops MongoDB 4.2 support, making MongoDB 4.4 (wire version 9) the new minimum. Removes code paths that only applied to servers older than 4.4.
Test Plan
Standard test suite. Evergreen matrix drops 4.2 and adds 9.0.
Checklist
Checklist for Author
Checklist for Reviewer