Skip to content

Document Range and String algorithms in ClientEncryption#encrypt - #3100

Open
comandeo-mongo wants to merge 2 commits into
mongodb:masterfrom
comandeo-mongo:encrypt-doc-fixes
Open

Document Range and String algorithms in ClientEncryption#encrypt#3100
comandeo-mongo wants to merge 2 commits into
mongodb:masterfrom
comandeo-mongo:encrypt-doc-fixes

Conversation

@comandeo-mongo

Copy link
Copy Markdown
Contributor

Documentation only, no behaviour change.

ClientEncryption#encrypt still described only the Indexed and Unindexed algorithms, even though Range and String have both been supported for a while. As a result:

  • Range was missing from the list of valid :algorithm values.
  • :range_opts and :string_opts were not documented at all.
  • :contention_factor and query_type were described as applying only to Indexed.
  • The @raise clause claimed ArgumentError is raised unless the algorithm is Indexed, while the code accepts Indexed, Range and String.

This also adds the note the client-side encryption spec requires drivers to document (spec): a payload produced by the Indexed, Range or String algorithm has to be inserted or queried through a client configured with :auto_encryption_options, where :bypass_query_analysis may be true but :bypass_auto_encryption must be false.

The same corrections are applied to Mongo::Crypt::ExplicitEncrypter#encrypt, which ClientEncryption#encrypt delegates to and whose docs had drifted further.

Verified with RuboCop and by running spec/mongo/client_encryption_spec.rb, spec/mongo/crypt/explicit_encryption_context_spec.rb and spec/integration/client_side_encryption/string_explicit_encryption_prose_spec.rb against a local 9.0 replica set.

The docs for #encrypt still described only the Indexed and Unindexed
algorithms, so Range was missing from the algorithm list, range_opts and
string_opts were undocumented, and the @raise clause named the wrong set
of algorithms.

Also add the note the client-side encryption spec requires drivers to
document: payloads produced by the Indexed, Range and String algorithms
have to be inserted or queried through a client configured with
:auto_encryption_options.

Same fixes applied to ExplicitEncrypter#encrypt, which #encrypt
delegates to.
Copilot AI review requested due to automatic review settings August 6, 2026 11:13
@comandeo-mongo
comandeo-mongo requested a review from a team as a code owner August 6, 2026 11:13
@comandeo-mongo
comandeo-mongo requested a review from jamis August 6, 2026 11:13

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.

Pull request overview

Updates the API documentation for explicit encryption to accurately describe the currently supported Queryable Encryption algorithms and related options, aligning ClientEncryption#encrypt and Mongo::Crypt::ExplicitEncrypter#encrypt docs with existing driver behavior.

Changes:

  • Document Range and String as valid :algorithm values for explicit encryption.
  • Document :range_opts / :string_opts and clarify how :contention_factor / :query_type apply across algorithms.
  • Add a spec-required note about using :auto_encryption_options when inserting/querying payloads produced by Queryable Encryption algorithms.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/mongo/crypt/explicit_encrypter.rb Expands YARD docs for algorithm/option applicability for explicit encryption.
lib/mongo/client_encryption.rb Updates ClientEncryption#encrypt documentation to include Range/String algorithms, options, and required usage note.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# "String". If not provided, it defaults to a value of 0. Contention factor
# should be set only if encryption algorithm is set to "Indexed", "Range",
# or "String".
# @option options [ String | nil ] query_type Query type to be applied
Comment thread lib/mongo/crypt/explicit_encrypter.rb Outdated
# "String". If not provided, it defaults to a value of 0. Contention
# factor should be set only if encryption algorithm is set to "Indexed",
# "Range", or "String".
# @option options [ String | nil ] query_type Query type to be applied
@comandeo-mongo
comandeo-mongo requested a review from Jibola August 6, 2026 11:24
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