Skip to content

Commit 906010b

Browse files
authored
MONGOCRYPT-946: improve error message when using "textPreview" (#1195)
1 parent 2d1965e commit 906010b

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/mongocrypt-ctx.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,9 @@ bool mongocrypt_ctx_setopt_algorithm(mongocrypt_ctx_t *ctx, const char *algorith
248248
} else if (mstr_eq_ignore_case(algo_str, mstrv_lit(MONGOCRYPT_ALGORITHM_STRING_STR))) {
249249
ctx->opts.index_type.value = MONGOCRYPT_INDEX_TYPE_STRING;
250250
ctx->opts.index_type.set = true;
251+
} else if (mstr_eq_ignore_case(algo_str, mstrv_lit(MONGOCRYPT_ALGORITHM_TEXTPREVIEW_DEPRECATED_STR))) {
252+
_mongocrypt_ctx_fail_w_msg(ctx, "Algorithm 'textPreview' is deprecated, please use 'string'");
253+
return false;
251254
} else {
252255
char *error = bson_strdup_printf("unsupported algorithm string \"%.*s\"",
253256
algo_str.len <= (size_t)INT_MAX ? (int)algo_str.len : INT_MAX,

test/test-mongocrypt-ctx-encrypt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4503,7 +4503,7 @@ static void _test_textPreview_fails(_mongocrypt_tester_t *tester) {
45034503
mongocrypt_ctx_t *ctx = mongocrypt_ctx_new(crypt);
45044504
ASSERT_FAILS(mongocrypt_ctx_setopt_algorithm(ctx, MONGOCRYPT_ALGORITHM_TEXTPREVIEW_DEPRECATED_STR, -1),
45054505
ctx,
4506-
"unsupported algorithm");
4506+
"please use 'string'");
45074507
mongocrypt_ctx_destroy(ctx);
45084508
mongocrypt_destroy(crypt);
45094509
}

0 commit comments

Comments
 (0)