Query analysis expects the jsonSchema attached to the create command to match the $jsonSchema specified in the validator.
Steps to reproduce:
import { MongoClient } from 'mongodb'; const client = await MongoClient.connect('mongodb://localhost/', { autoEncryption: { kmsProviders: { local: { key: 'A'.repeat(128) } }, extraOptions: { //cryptSharedLibPath: './lib/mongo_crypt_v1.so', mongocryptdSpawnPath: './mongocryptd' } } }); await client.db('test').createCollection('test1', { validator: { $jsonSchema: { properties: { a: { bsonType: 'number' }, }, }, }, }); await client.close();
fails with:
csfle "analyze_query" failed: validator with $jsonSchema must be identical to FLE 1 jsonSchema parameter. [Error 2, code 6491101]
libmongocrypt appends an empty jsonSchema document to the command sent to query analysis:
{ ns: 'test.$cmd', rawCommand: { create: 'test1', validator: { '$jsonSchema': { bsonType: 'object', properties: { a: { bsonType: 'number' } } } }, jsonSchema: {}, isRemoteSchema: true } }
- is related to
-
MONGOCRYPT-429 Do not bypass create, collMod, or createIndexes
- Closed