{"record":{"id":"3d31f01356f46aaa","repo":"mongodb/node-mongodb-native","slug":"unknown-state-getstate","errorCode":null,"errorMessage":"Unknown state: ${getState()}","messagePattern":"Unknown state: (.+?)","errorType":"exception","errorClass":"MongoCryptError","httpStatus":null,"severity":"critical","filePath":"src/client-side-encryption/state_machine.ts","lineNumber":280,"sourceCode":"\n        case MONGOCRYPT_CTX_NEED_KMS: {\n          await Promise.all(this.requests(context, options));\n          context.finishKMSRequests();\n          break;\n        }\n\n        case MONGOCRYPT_CTX_READY: {\n          const finalizedContext = context.finalize();\n          if (getState() === MONGOCRYPT_CTX_ERROR) {\n            const message = getStatus().message || 'Finalization error';\n            throw new MongoCryptError(message);\n          }\n          result = finalizedContext;\n          break;\n        }\n\n        default:\n          throw new MongoCryptError(`Unknown state: ${getState()}`);\n      }\n    }\n\n    if (getState() === MONGOCRYPT_CTX_ERROR || result == null) {\n      const message = getStatus().message;\n      if (!message) {\n        debug(\n          `unidentifiable error in MongoCrypt - received an error status from \\`libmongocrypt\\` but received no error message.`\n        );\n      }\n      throw new MongoCryptError(\n        message ??\n          'unidentifiable error in MongoCrypt - received an error status from `libmongocrypt` but received no error message.'\n      );\n    }\n\n    return result;\n  }","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/mongodb/node-mongodb-native/blob/dce7939f86fb283e167ad709955abedb7bf23124/src/client-side-encryption/state_machine.ts#L262-L298","documentation":"Defensive default branch in the CSFLE state machine switch — libmongocrypt returned a numeric state value that the driver does not recognise. This indicates a version mismatch: the linked libmongocrypt/crypt_shared introduced a new state constant the driver's bindings do not handle.","triggerScenarios":"Using a newer crypt_shared/libmongocrypt than the driver supports, or vice versa, exposing an unmapped state integer; a corrupted context object reporting a garbage state value.","commonSituations":"Upgrading crypt_shared independently of the mongodb driver; using an older driver with a newer libmongocrypt; custom/edge builds of libmongocrypt.","solutions":["Pin compatible versions of mongodb, mongodb-client-encryption, and libmongocrypt/crypt_shared per the driver's CSFLE compatibility table.","Upgrade the mongodb driver to a release that supports your libmongocrypt/crypt_shared version, or downgrade crypt_shared to match the driver.","If using crypt_shared, ensure the loaded .dll/.so/.dylib is the one shipped with your mongodb-client-encryption build."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin compatible mongodb + mongodb-client-encryption + crypt_shared/libmongocrypt versions.","Do not mix a newer crypt_shared with an older driver."],"tags":["csfle","client-side-encryption","internal","version-skew","libmongocrypt"],"backgroundTag":null,"analyzedSha":"dce7939f86fb283e167ad709955abedb7bf23124","analyzedAt":"2026-08-11T04:54:53.215Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}