[MONGOCRYPT-436] create command to query analysis does not include non-CSFLE jsonSchema Created: 02/Jun/22  Updated: 28/Oct/23  Resolved: 05/Jun/22

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: 1.5.0-rc0
Fix Version/s: 1.5.0-rc2, 1.5.0

Type: Bug Priority: Unknown
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to MONGOCRYPT-429 Do not bypass create, collMod, or cre... Closed
Binding Changes: Not Needed

 Description   

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
  }
}



 Comments   
Comment by Githook User [ 05/Jun/22 ]

Author:

{'name': 'Kevin Albertson', 'email': 'kevin.albertson@mongodb.com', 'username': 'kevinAlbs'}

Message: MONGOCRYPT-436 use $jsonSchema from `create` command (#360)
Branch: master
https://github.com/mongodb/libmongocrypt/commit/6b714072dcef8e5becda068b0ea19941ac6aaf0d

Generated at Thu Feb 08 09:08:40 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.