Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-69564

Query analysis omits version API fields with "explain"

    • Fully Compatible
    • ALL
    • Hide

      Steps to reproduce with mongo_crypt:

      Build the "csfle-markup" tool. It is a tool in libmongocrypt to mark up commands with the mongo_crypt shared library.

      % git clone https://github.com/mongodb/libmongocrypt.git libmongocrypt-explain-with-apiVersion
      % cd libmongocrypt-explain-with-apiVersion
      % cmake .
      % cmake --build . --target csfle-markup
      

      Mark the explain-with-apiVersion.json through csfle-markup:

      % cat ../explain-with-apiVersion.json | ./csfle-markup ~/bin/crypt_shared-6.0.0/lib/mongo_crypt_v1.dylib | jq .
      Loaded csfle library [/Users/kevin.albertson/bin/crypt_shared-6.0.0/lib/mongo_crypt_v1.dylib]: mongo_crypt_v1-dev-6.0.0
      {
        "hasEncryptionPlaceholders": false,
        "schemaRequiresEncryption": false,
        "result": {
          "explain": {
            "find": "default",
            "filter": {}
          },
          "verbosity": "allPlansExecution"
        }
      }
      
      Show
      Steps to reproduce with mongo_crypt: Build the "csfle-markup" tool. It is a tool in libmongocrypt to mark up commands with the mongo_crypt shared library. % git clone https: //github.com/mongodb/libmongocrypt.git libmongocrypt-explain-with-apiVersion % cd libmongocrypt-explain-with-apiVersion % cmake . % cmake --build . --target csfle-markup Mark the explain-with-apiVersion.json through csfle-markup : % cat ../explain-with-apiVersion.json | ./csfle-markup ~/bin/crypt_shared-6.0.0/lib/mongo_crypt_v1.dylib | jq . Loaded csfle library [/Users/kevin.albertson/bin/crypt_shared-6.0.0/lib/mongo_crypt_v1.dylib]: mongo_crypt_v1-dev-6.0.0 { "hasEncryptionPlaceholders" : false , "schemaRequiresEncryption" : false , "result" : { "explain" : { "find" : " default " , "filter" : {} }, "verbosity" : "allPlansExecution" } }
    • Security 2022-11-14, Security 2022-12-12, Security 2022-12-26, Security 2023-01-09

      The "apiVersion", "apiStrict", and "apiDeprecationErrors" fields do not appear to be returned in the results of mongocryptd or the mongo_crypt shared library.

      mongocryptd omits "apiStrict" or "apiDeprecationErrors".

      mongo_crypt omits "apiVersion", "apiStrict" or "apiDeprecationErrors".

      For example, marking up the following with mongo_crypt:

      {
          "explain": {
              "find": "default",
              "filter": {},
              "$db": "db"
          },
          "$db": "db",
          "apiVersion": "1",
          "apiStrict": "true",
          "apiDeprecationErrors": true,
          "jsonSchema": {},
          "isRemoteSchema": false
      }
      

      Results in this output:

      {
          "hasEncryptionPlaceholders": false,
          "schemaRequiresEncryption": false,
          "result": {
              "explain": {
              "find": "default",
              "filter": {}
              },
              "verbosity": "allPlansExecution"
          }
      }
      

      "apiVersion", "apiStrict", and "apiDeprecationErrors" is expected in the output.

      The output is the same for version mongo_crypt_v1-dev-6.2.0-alpha-336-ga7ba740.

      Marking an explain command with mongocryptd does not appear to preserve "apiStrict" or "apiDeprecationErrors" in the output.

      // Run against mongocryptd with: mongo --port 27020 explain-with-apiVersion.js
      var cmd = {
          "explain": {
              "find": "default",
              "filter": {}
          },
          "apiVersion": "1",
          "apiStrict": false,
          "apiDeprecationErrors": false,
          "jsonSchema": {},
          "isRemoteSchema": false
      }
      
      var got = db.runCommand(cmd)
      printjson(got)
      
      /*
      Prints:
      
      {
              "hasEncryptionPlaceholders" : false,
              "schemaRequiresEncryption" : false,
              "result" : {
                      "explain" : {
                              "find" : "default",
                              "filter" : {
      
                              }
                      },
                      "verbosity" : "allPlansExecution",
                      "apiVersion" : "1"
              },
              "ok" : 1
      }
      */
      

      The output is the same for version 6.1.0-alpha-986-g960265d

        1. explain-with-apiVersion.js
          0.7 kB
        2. explain-with-apiVersion.json
          0.2 kB

            Assignee:
            shreyas.kalyan@mongodb.com Shreyas Kalyan
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: