Skip to content

PYTHON-5959 Drop prefixPreview, suffixPreview, and substringPreview APIs - #3181

Merged
blink1073 merged 6 commits into
mongodb:mainfrom
blink1073:PYTHON-5959
Nov 9, 2026
Merged

blink1073 merged 6 commits into
mongodb:mainfrom
blink1073:PYTHON-5959

Conversation

@blink1073

@blink1073 blink1073 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

PYTHON-5959

Changes in this PR

Removes the beta QueryType.PREFIXPREVIEW, SUFFIXPREVIEW, and SUBSTRINGPREVIEW query types; use the stable QueryType.PREFIX, QueryType.SUFFIX, and QueryType.SUBSTRING instead. libmongocrypt 1.21.0 (MONGOCRYPT-938) makes the preview query types a runtime error.

  • Raised the pymongocrypt requirement to 1.21.0, the release that removed the preview query types.
  • Made the string explicit encryption prose tests GA-only: they now require MongoDB 9.0+ and libmongocrypt 1.19.0+.
  • Removed the preview test data, spec tests, and the Evergreen preview task, so encryption CI always tests the GA types against the pinned libmongocrypt.

Test Plan

  • Added a regression test asserting the preview query types are gone from QueryType.
  • Ran the encryption suites on the Evergreen patch build: all 9 tasks passed, with the string prose tests exercising the GA query types against server 9.0 and libmongocrypt 1.21.0.
  • The prose tests skip locally without server 9.0+ and libmongocrypt 1.19+, so the patch build carries the real coverage.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s). None identified.

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues block the transition from preview string-encryption query types to the stable APIs.

No open issues 🎉

What changed in this PR

Removes PyMongo’s beta string-encryption query types in favor of the stable APIs, aligning encryption support and CI with libmongocrypt 1.21.0.

Changes:

  • Removes preview QueryType members and documents their stable replacements.
  • Makes string-encryption prose tests GA-only, adds removal regression coverage, and deletes preview fixtures and spec tests.
  • Raises the pymongocrypt requirement to 1.21.0, updates the CI library pin, and removes preview-only Evergreen tasks.
File Description
test/​test_encryption.py Mirrors GA-only tests and preview-removal regression coverage.
test/​client-side-encryption/​spec/​unified/​QE-Text-suffixPreview.json Deletes suffix-preview spec tests.
test/​client-side-encryption/​spec/​unified/​QE-Text-substringPreview.json Deletes substring-preview spec tests.
test/​client-side-encryption/​spec/​unified/​QE-Text-prefixPreview.json Deletes prefix-preview spec tests.
test/​client-side-encryption/​etc/​data/​encryptedFields-substring-preview.json Deletes the substring-preview fixture.
test/​client-side-encryption/​etc/​data/​encryptedFields-prefix-suffix-preview.json Deletes the prefix/suffix-preview fixture.
test/​asynchronous/​test_encryption.py Uses stable query types and verifies preview members are removed.
requirements/​encryption.txt Raises the minimum pymongocrypt version to 1.21.0.
pymongo/​encryption_shared.py Removes preview enum members and documents the API change.
doc/​changelog.rst Documents removal and replacement requirements.
.evergreen/​scripts/​setup_tests.py Pins libmongocrypt 1.21.0 and removes preview-specific dependency setup.
.evergreen/​scripts/​generate_config.py Removes preview task generation and selection.
.evergreen/​generated_configs/​variants.yml Removes preview tasks from encryption variants.
.evergreen/​generated_configs/​tasks.yml Deletes the generated preview task.

Review effort: Balanced

@blink1073
blink1073 marked this pull request as ready for review November 6, 2026 21:31
@blink1073
blink1073 requested a review from a team as a code owner November 6, 2026 21:31
@blink1073
blink1073 requested a review from NoahStapp November 6, 2026 21:31

@NoahStapp NoahStapp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove _string_opts_kwarg too now that text_opts is no longer supported?

Comment thread doc/changelog.rst
Comment on lines +9 to +12
- Removed the beta ``QueryType.PREFIXPREVIEW``, ``QueryType.SUFFIXPREVIEW``,
and ``QueryType.SUBSTRINGPREVIEW`` query types. Use ``QueryType.PREFIX``,
``QueryType.SUFFIX``, and ``QueryType.SUBSTRING`` instead (requires MongoDB
9.0+ and pymongocrypt 1.21.0+) (`PYTHON-5959`_).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should mention that this change also removes support for text_opts in favor of string_opts due to the pymongocrypt version bump.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread doc/changelog.rst

- The client handshake metadata now reports a detected coding agent in
``client.env.agent`` (`PYTHON-5929`_).
- Removed the beta ``QueryType.PREFIXPREVIEW``, ``QueryType.SUFFIXPREVIEW``,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should all use Sphinx role cross-references as per CODING-STANDARDS.md.

@blink1073 blink1073 Nov 9, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't link to things that are removed

@blink1073
blink1073 requested a review from NoahStapp November 9, 2026 16:12

@NoahStapp NoahStapp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a general question that this PR raised for me: this change requires pymongocrypt>=1.21.0,<2.0.0 for PyMongo 4.20. Shouldn't that mean that our encryption tests will always be using at least that version and so we don't need any gates or compatibility checks at all?

Comment thread doc/changelog.rst Outdated
- Removed the deprecated ``text_opts`` parameter of
:meth:`~pymongo.encryption.ClientEncryption.encrypt` and
:meth:`~pymongo.asynchronous.encryption.AsyncClientEncryption.encrypt`.
Use ``string_opts`` (`PYTHON-5959`_).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Use ``string_opts`` (`PYTHON-5959`_).
Use ``string_opts`` instead (`PYTHON-5959`_).

Comment thread pymongo/encryption_options.py Outdated
@@ -422,12 +422,6 @@ class TextOpts(StringOpts):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this class entirely now that it's fully removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread test/asynchronous/test_encryption.py Outdated
string_opts = StringOpts(prefix={"strMinQueryLength": 2, "strMaxQueryLength": 10})
with self.assertRaises(ConfigurationError):
encryption._resolve_string_opts(string_opts, string_opts)
def test_text_opts_is_removed(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this test adds meaningful coverage, especially since it needs to type: ignore two different arguments on an unbound method call.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment thread test/asynchronous/test_encryption.py Outdated
params = inspect.signature(encryption.AsyncExplicitEncrypter.encrypt).parameters
self.assertIn(encryption._string_opts_kwarg(), params)
class TestPreviewQueryTypesRemoved(AsyncPyMongoTestCase):
def test_preview_query_types_removed(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here, do we need to explicitly test that removed code no longer works?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@async_client_context.require_libmongocrypt_min(1, 18, 1)
@async_client_context.require_version_min(9, 0, -1)
@async_client_context.require_libmongocrypt_min(1, 19, 0)
@async_client_context.require_pymongocrypt_min(1, 16, 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can ever run a test with encryption that will fail this gate, should we just remove it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened PYTHON-6233

@blink1073
blink1073 requested a review from NoahStapp November 9, 2026 17:24
@blink1073

Copy link
Copy Markdown
Member Author

GHA failures are tracked in DRIVERS-3728

@NoahStapp NoahStapp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@blink1073
blink1073 merged commit 4a45af5 into mongodb:main Nov 9, 2026
50 of 61 checks passed
@blink1073
blink1073 deleted the PYTHON-5959 branch November 9, 2026 19:44
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