Uploaded image for project: 'Libmongocrypt'
  1. Libmongocrypt
  2. MONGOCRYPT-436

create command to query analysis does not include non-CSFLE jsonSchema

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.5.0-rc2, 1.5.0
    • Affects Version/s: 1.5.0-rc0
    • Component/s: None
    • None
    • Not Needed

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

            Assignee:
            kevin.albertson@mongodb.com Kevin Albertson
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: