Skip to content

Conversation

mdb-ad
Copy link
Contributor

@mdb-ad mdb-ad commented Aug 11, 2025

No description provided.

@mdb-ad mdb-ad changed the title Text search explicit encryption API and prose tests CDRIVER-6044 Text search explicit encryption API and prose tests Aug 28, 2025
@mdb-ad mdb-ad marked this pull request as ready for review August 28, 2025 06:32
@mdb-ad mdb-ad requested a review from a team as a code owner August 28, 2025 06:32
@mdb-ad mdb-ad requested review from Julia-Garland and kevinAlbs and removed request for Julia-Garland August 28, 2025 06:32

void
mongoc_encrypt_text_opts_destroy(mongoc_encrypt_text_opts_t *topts)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

For consistency with other _destroy functions, return if argument is NULL:

   if (!topts) {
      return;
   }

I expect this may fix ASan tasks:

mongoc-client-side-encryption.c:636:51: runtime error: member access within null pointer of type 'mongoc_encrypt_text_opts_t' (aka 'struct _mongoc_encrypt_text_opts_t')

@@ -182,6 +190,67 @@ mongoc_client_encryption_get_key(mongoc_client_encryption_t *client_encryption,
bson_t *key_doc,
bson_error_t *error);

MONGOC_EXPORT(mongoc_encrypt_text_prefix_opts_t *)
mongoc_encrypt_text_prefix_opts_new(void);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add .rst docs for the new API.

BSON_ASSERT_PARAM(bson_text_opts);
BSON_ASSERT_PARAM(opts);

BSON_ASSERT(BSON_APPEND_BOOL(bson_text_opts, "caseSensitive", opts->case_sensitive));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I expect caseSensitive and diacriticSensitive should only be applied if set, like:

if (opts->diacritic_sensitive.set) {
    BSON_ASSERT(BSON_APPEND_BOOL(bson_text_opts, "diacriticSensitive", opts->diacritic_sensitive.value));
}

The current implementation defaults to false. The spec requires these be set. If a user does not set either field, I expect libmongocrypt will error.

"subType": "04"
}
},
"path": "encrypted-textPreview",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest updating the encryptedFields files to match what is in the spec. The spec refers to "encryptedText".

@@ -1668,6 +1671,18 @@ _create_explicit_state_machine(_mongoc_crypt_t *crypt,
mongocrypt_binary_destroy(binary_range_opts);
}

if (text_opts != NULL) {
/* mongocrypt error checks and parses range options */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/* mongocrypt error checks and parses range options */
/* mongocrypt error checks and parses text options */

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