{"record":{"id":"1cbf6dbcb46314f7","repo":"Automattic/mongoose","slug":"encryptiontype-must-be-provided","errorCode":null,"errorMessage":"encryptionType must be provided","messagePattern":"encryptionType must be provided","errorType":"exception","errorClass":"MongooseError","httpStatus":null,"severity":"error","filePath":"lib/schema.js","lineNumber":928,"sourceCode":"      }\n    }\n\n    if (val.instanceOfSchema && val.encryptionType() != null) {\n      // schema.add({ field: <instance of encrypted schema> })\n      if (this.encryptionType() != val.encryptionType()) {\n        throw new MongooseError('encryptionType of a nested schema must match the encryption type of the parent schema.');\n      }\n\n      for (const [encryptedField, encryptedFieldConfig] of Object.entries(val.encryptedFields)) {\n        const path = fullPath + '.' + encryptedField;\n        this._addEncryptedField(path, encryptedFieldConfig);\n      }\n    } else if (typeof val === 'object' && 'encrypt' in val) {\n      // schema.add({ field: { type: <schema type>, encrypt: { ... }}})\n      const { encrypt } = val;\n\n      if (this.encryptionType() == null) {\n        throw new MongooseError('encryptionType must be provided');\n      }\n\n      this._addEncryptedField(fullPath, encrypt);\n    } else {\n      // if the field was already encrypted and we re-configure it to be unencrypted, remove\n      // the encrypted field configuration\n      this._removeEncryptedField(fullPath);\n    }\n  }\n\n  const aliasObj = Object.fromEntries(\n    Object.entries(obj).map(([key]) => ([prefix + key, null]))\n  );\n  aliasFields(this, aliasObj);\n  return this;\n};\n\n/**","sourceCodeStart":910,"sourceCodeEnd":946,"githubUrl":"https://github.com/Automattic/mongoose/blob/49cdab01366679723b487ecb754b38570f783289/lib/schema.js#L910-L946","documentation":"Error \"encryptionType must be provided\" thrown in Automattic/mongoose.","triggerScenarios":"Thrown at lib/schema.js:928 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"49cdab01366679723b487ecb754b38570f783289","analyzedAt":"2026-08-21T22:54:00.882Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}