[SERVER-69564] Query analysis omits version API fields with "explain" Created: 09/Sep/22  Updated: 29/Oct/23  Resolved: 29/Dec/22

Status: Closed
Project: Core Server
Component/s: Field Level Encryption
Affects Version/s: None
Fix Version/s: 6.3.0-rc0

Type: Bug Priority: Major - P3
Reporter: Kevin Albertson Assignee: Shreyas Kalyan
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File explain-with-apiVersion.js     File explain-with-apiVersion.json    
Issue Links:
Problem/Incident
causes PHPLIB-947 Failure in test-requireApiVersion tas... Closed
Related
related to SERVER-77040 Append API version fields to root of ... Closed
related to DRIVERS-2612 Bump minServerVersion for CSFLE deter... Implementing
is related to SERVER-58293 mongocryptd does not include server A... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

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

Sprint: Security 2022-11-14, Security 2022-12-12, Security 2022-12-26, Security 2023-01-09
Participants:

 Description   

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



 Comments   
Comment by Githook User [ 29/Dec/22 ]

Author:

{'name': 'Shreyas Kalyan', 'email': 'shreyas.kalyan@mongodb.com', 'username': 'shreyaskal'}

Message: SERVER-69564 Query analysis omits version API fields with explain
Branch: master
https://github.com/10gen/mongo-enterprise-modules/commit/a2be4f870e20382e3c802a33fc536d23309a36d4

Generated at Thu Feb 08 06:13:48 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.