{"record":{"id":"12f393c10756abde","repo":"tursodatabase/turso","slug":"encryption-is-not-supported-in-this-build","errorCode":null,"errorMessage":"Encryption is not supported in this build","messagePattern":"Encryption is not supported in this build","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"bindings/javascript/packages/native/compat.ts","lineNumber":7,"sourceCode":"import { DatabaseCompat, NativeDatabase, SqliteError, DatabaseOpts, EncryptionCipher } from \"@tursodatabase/database-common\"\nimport { Database as NativeDB, EncryptionCipher as NativeEncryptionCipher } from \"#index\";\n\n// Map string cipher names to native enum values (lazy to avoid errors if native module lacks encryption)\nfunction getCipherValue(cipher: EncryptionCipher): number {\n    if (!NativeEncryptionCipher) {\n        throw new Error('Encryption is not supported in this build');\n    }\n    const cipherMap: Record<EncryptionCipher, number> = {\n        'aes128gcm': NativeEncryptionCipher.Aes128Gcm,\n        'aes256gcm': NativeEncryptionCipher.Aes256Gcm,\n        'aegis256': NativeEncryptionCipher.Aegis256,\n        'aegis256x2': NativeEncryptionCipher.Aegis256x2,\n        'aegis128l': NativeEncryptionCipher.Aegis128l,\n        'aegis128x2': NativeEncryptionCipher.Aegis128x2,\n        'aegis128x4': NativeEncryptionCipher.Aegis128x4,\n    };\n    return cipherMap[cipher];\n}\n\nclass Database extends DatabaseCompat {\n    constructor(path: string, opts: DatabaseOpts = {}) {\n        const nativeOpts: any = { ...opts };\n        if (opts.encryption) {\n            nativeOpts.encryption = {","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/tursodatabase/turso/blob/bad083fafbefdeae9a42ec19bdaaad8918dcf411/bindings/javascript/packages/native/compat.ts#L1-L25","documentation":"getCipherValue() in the native compat layer maps cipher names ('aes256gcm', 'aegis256', ...) to the native EncryptionCipher enum, but builds the map lazily so the module still loads when the native addon lacks encryption. If the imported NativeEncryptionCipher is undefined — the binary was compiled without encryption support — passing any encryption option throws this error at Database construction. It is a build-capability error, not a wrong-cipher error.","triggerScenarios":"new Database(path, { encryptionKey, encryptionCipher }) on @tursodatabase/database-native compat flavor where the loaded native binary has no EncryptionCipher export; older prebuilt platform binaries; self-compiled addons without the encryption feature enabled.","commonSituations":"Upgrading the JS packages without upgrading the native binary (or vice versa); optionalDependencies pulling a stale platform package; CI using a minimal local build; deploying on a platform whose prebuilt artifact lacks encryption.","solutions":["Upgrade the @tursodatabase/native package (and its platform binaries) to a version built with encryption support.","If building the addon from source, enable the encryption feature when compiling.","Feature-check before constructing: import { EncryptionCipher } from '#index' and verify it is non-null.","If encryption is optional in your app, degrade gracefully by dropping encryptionKey/encryptionCipher."],"exampleFix":"// before\nimport { EncryptionCipher } from '#index';\nconst db = new Database('app.db', { encryptionKey, encryptionCipher: 'aes256gcm' }); // throws if build lacks encryption\n\n// after\nimport { EncryptionCipher } from '#index';\nif (!EncryptionCipher) {\n  throw new Error('native build lacks encryption; upgrade @tursodatabase/native platform binaries');\n}\nconst db = new Database('app.db', { encryptionKey, encryptionCipher: 'aes256gcm' });","handlingStrategy":"type-guard","validationCode":"import { EncryptionCipher } from '#index';\nif (EncryptionCipher == null) {\n  throw new Error('this native build lacks encryption; upgrade the native package before using encryptionKey');\n}\nconst db = new Database(path, { encryptionKey, encryptionCipher: 'aes256gcm' });","typeGuard":"const supportsEncryption = (enc: unknown): enc is Record<string, number> =>\n  enc != null && typeof (enc as Record<string, unknown>).Aes256Gcm === 'number';","tryCatchPattern":"try { new Database(path, opts); } catch (e) { if (e instanceof Error && /Encryption is not supported/.test(e.message)) { /* fall back: open unencrypted or upgrade native binary */ } else throw e; }","preventionTips":["Run a startup feature check on the EncryptionCipher import before opening encrypted databases.","Keep the JS wrapper and native platform packages upgraded together.","Pin native package versions whose prebuilt binaries include encryption."],"tags":["encryption","native-module","build-features","javascript"],"backgroundTag":"feature-not-available-in-build","analyzedSha":"bad083fafbefdeae9a42ec19bdaaad8918dcf411","analyzedAt":"2026-08-16T23:12:11.798Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}