{"record":{"id":"30c1bdeb2bc47941","repo":"pubkey/rxdb","slug":"ut6","errorCode":"UT6","errorMessage":"\n        RxDB Error-Code: ${message}.\n        Hint: Error messages are not included in RxDB core to reduce build size.\n        To show the full error messages and to ensure that you do not make any mistakes when using RxDB,\n        use the dev-mode plugin when you are in development mode: https://rxdb.info/dev-mode.html?console=error\n        \nFind out more about this error here: https://rxdb.info/errors.html?console=errors#UT6 \nStill stuck? Ask in the RxDB Discord: https://rxdb.info/chat \n","messagePattern":"\n        RxDB Error-Code: (.+?)\\.\n        Hint: Error messages are not included in RxDB core to reduce build size\\.\n        To show the full error messages and to ensure that you do not make any mistakes when using RxDB,\n        use the dev-mode plugin when you are in development mode: https://rxdb\\.info/dev-mode\\.html\\?console=error\n        \nFind out more about this error here: https://rxdb\\.info/errors\\.html\\?console=errors#UT6 \nStill stuck\\? Ask in the RxDB Discord: https://rxdb\\.info/chat \n","errorType":"error_code","errorClass":"RxError","httpStatus":null,"severity":"error","filePath":"src/rx-storage-helper.ts","lineNumber":877,"sourceCode":"    };\n\n    database.storageInstances.add(ret);\n    return ret;\n}\n\n/**\n * Each RxStorage implementation should\n * run this method at the first step of createStorageInstance()\n * to ensure that the configuration is correct.\n */\nexport function ensureRxStorageInstanceParamsAreCorrect(\n    params: RxStorageInstanceCreationParams<any, any>\n) {\n    if (params.schema.keyCompression) {\n        throw newRxError('UT5', { args: { params } });\n    }\n    if (hasEncryption(params.schema)) {\n        throw newRxError('UT6', { args: { params } });\n    }\n    if (\n        params.schema.attachments &&\n        params.schema.attachments.compression\n    ) {\n        throw newRxError('UT7', { args: { params } });\n    }\n}\n\nexport function hasEncryption(jsonSchema: RxJsonSchema<any>): boolean {\n    if (\n        (!!jsonSchema.encrypted && jsonSchema.encrypted.length > 0) ||\n        (jsonSchema.attachments && jsonSchema.attachments.encrypted)\n    ) {\n        return true;\n    } else {\n        return false;\n    }","sourceCodeStart":859,"sourceCodeEnd":895,"githubUrl":"https://github.com/pubkey/rxdb/blob/af6fb65f94cd70558d74c23799eda11ff1c15224/src/rx-storage-helper.ts#L859-L895","documentation":"UT6 is thrown by ensureRxStorageInstanceParamsAreCorrect (src/rx-storage-helper.ts:877) when the schema contains field-level encryption (a non-empty 'encrypted' array or encryption-enabled fields detected by hasEncryption) but the storage instance is being created for a context where encryption is not allowed. The guard ensures storages that cannot handle encrypted field params fail at creation time with a clear code instead of failing later during writes.","triggerScenarios":"Creating a collection whose RxJsonSchema declares encrypted fields (schema.encrypted array or hasEncryption detection) with a storage configuration that runs this params guard and must not receive encryption settings, e.g. internal storages that create plain instances on top of an encrypted parent collection.","commonSituations":"Using the encryption plugin fields together with storages or helper paths that create secondary storage instances (replication metastores, migration storage, internal RxDB store) which inherit the schema but must be plain; forgetting that field-level encryption requires the encryption plugin and only applies to the primary collection storage, not derived instances.","solutions":["Remove the 'encrypted' array from the schema if you do not need field-level encryption.","If you need encryption, register the RxDB encryption plugin and provide the password when creating the database, and create the collection through the normal RxCollection path (not a raw storage instance).","Do not pass an encrypted schema into ensureRxStorageInstanceCreationParams for internal/secondary instances; strip encryption for derived storages.","Check hasEncryption(jsonSchema) yourself before creating a storage instance to detect this configuration early."],"exampleFix":"// before: encrypted fields passed to a plain storage instance\nconst params = { schema: { ...mySchema, encrypted: ['secret'] }, storage: plainStorage };\nensureRxStorageInstanceParamsAreCorrect(params); // UT6\n\n// after: strip encryption for internal/secondary instances\nconst params = { schema: { ...mySchema, encrypted: undefined }, storage: plainStorage };\nensureRxStorageInstanceParamsAreCorrect(params);","handlingStrategy":"validation","validationCode":"// detect field-level encryption in the schema before creating the instance\nfunction hasEncryption(jsonSchema) {\n  return (\n    (!!jsonSchema.encrypted && jsonSchema.encrypted.length > 0) ||\n    Object.values(jsonSchema.properties || {}).some(p => p.encrypted === true || p.format === 'encrypted')\n  );\n}\n\nif (hasEncryption(mySchema) && !encryptionPluginRegistered) {\n  throw new Error('Encrypted schema requires the encryption plugin and password');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await myRxDatabase.addCollections({ secrets: { schema: encryptedSchema } });\n} catch (err) {\n  if (err && err.code === 'UT6') {\n    console.error('Encryption fields set but storage params disallow encryption');\n    return;\n  }\n  throw err;\n}","preventionTips":["Register the encryption plugin and pass a password when creating the database before using encrypted fields.","Never hand encryption settings into derived/internal storage instance params; keep encryption on the primary collection path.","Keep the 'encrypted' array in the schema minimal and reviewed, since it changes the storage requirements.","Run hasEncryption() checks in tests for every schema you ship."],"tags":["configuration","encryption","schema"],"backgroundTag":"incompatible-storage-config","analyzedSha":"af6fb65f94cd70558d74c23799eda11ff1c15224","analyzedAt":"2026-08-31T23:32:37.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}