{"id":"7e1c7d79d4b5eec2","repo":"mongodb/node-mongodb-native","slug":"driver-support-of-queryable-encryption-is-incompat","errorCode":null,"errorMessage":"Driver support of Queryable Encryption is incompatible with server. Upgrade server to use Queryable Encryption. The minimum server version required is 7.0","messagePattern":"Driver support of Queryable Encryption is incompatible with server\\. Upgrade server to use Queryable Encryption\\. The minimum server version required is 7\\.0","errorType":"exception","errorClass":"MongoCompatibilityError","httpStatus":null,"severity":"error","filePath":"src/operations/create_collection.ts","lineNumber":169,"sourceCode":"  const timeoutContext = TimeoutContext.create({\n    session: options.session,\n    serverSelectionTimeoutMS: db.client.s.options.serverSelectionTimeoutMS,\n    waitQueueTimeoutMS: db.client.s.options.waitQueueTimeoutMS,\n    timeoutMS: options.timeoutMS\n  });\n\n  const encryptedFields: Document | undefined =\n    options.encryptedFields ??\n    db.client.s.options.autoEncryption?.encryptedFieldsMap?.[`${db.databaseName}.${name}`];\n\n  if (encryptedFields) {\n    class CreateSupportingFLEv2CollectionOperation extends CreateCollectionOperation {\n      override buildCommandDocument(connection: Connection, session?: ClientSession): Document {\n        if (\n          !connection.description.loadBalanced &&\n          maxWireVersion(connection) < MIN_SUPPORTED_QE_WIRE_VERSION\n        ) {\n          throw new MongoCompatibilityError(\n            `${INVALID_QE_VERSION} The minimum server version required is ${MIN_SUPPORTED_QE_SERVER_VERSION}`\n          );\n        }\n\n        return super.buildCommandDocument(connection, session);\n      }\n    }\n\n    // Create auxilliary collections for queryable encryption support.\n    const escCollection = encryptedFields.escCollection ?? `enxcol_.${name}.esc`;\n    const ecocCollection = encryptedFields.ecocCollection ?? `enxcol_.${name}.ecoc`;\n\n    for (const collectionName of [escCollection, ecocCollection]) {\n      const createOp = new CreateSupportingFLEv2CollectionOperation(db, collectionName, {\n        clusteredIndex: {\n          key: { _id: 1 },\n          unique: true\n        },","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/3366c21a6311e02f1be91da982f9b93d3cce99a0/src/operations/create_collection.ts#L151-L187","documentation":"Thrown when creating a collection that has encryptedFields (Queryable Encryption / FLE 2) against a server whose wire protocol version is below the minimum required for Queryable Encryption (server < 7.0). The driver detects the incompatibility in buildCommandDocument and raises MongoCompatibilityError, directing the user to upgrade. This protects against silently sending unsupported commands.","triggerScenarios":"Calling db.createCollection(name, { encryptedFields: {...} }) (or having an autoEncryption.encryptedFieldsMap entry for the collection) while connected to a MongoDB server older than 7.0. Also triggered by Atlas proxy/wire-version downgrades.","commonSituations":"Developing Queryable Encryption locally against an older mongod; connecting to a legacy on-prem deployment; mismatched server version in CI vs production; using a shared cluster below 7.0.","solutions":["Upgrade the MongoDB server to 7.0 or newer before using Queryable Encryption.","Verify the server version with await db.admin().serverStatus() / hello() and ensure featureCompatibilityVersion >= 7.0.","If encryption is optional for this collection, remove the encryptedFields option / encryptedFieldsMap entry when targeting older servers."],"exampleFix":"// before (server < 7.0)\nawait db.createCollection('patients', {\n  encryptedFields: { fields: [...] }\n}); // throws\n\n// after\n// 1. Upgrade mongod to >= 7.0, then:\nawait db.createCollection('patients', {\n  encryptedFields: { fields: [...] }\n});\n// 2. Or omit encryptedFields on legacy servers.","handlingStrategy":"validation","validationCode":"const MIN_QE = 7.0;\nasync function assertQeSupported(db) {\n  const { version } = (await db.command('hello')).forEach ?? (await db.admin().serverInfo());\n  const major = Number(String(version ?? (await db.admin().buildInfo()).version).split('.')[0]);\n  if (major < MIN_QE) throw new Error('Server < 7.0, QE unsupported');\n}","typeGuard":"function isQeCapable(wireVersion): boolean {\n  return wireVersion >= 21; // min wire version for Queryable Encryption\n}","tryCatchPattern":null,"preventionTips":["Require MongoDB >= 7.0 for Queryable Encryption","Check featureCompatibilityVersion at startup","Conditionally omit encryptedFields on legacy servers","Pin CI server images to >= 7.0"],"tags":["queryable-encryption","csfle","server-version","compatibility","create-collection"],"analyzedSha":"3366c21a6311e02f1be91da982f9b93d3cce99a0","analyzedAt":"2026-08-04T13:40:15.335Z","schemaVersion":2}