{"record":{"id":"11b5c7150de0248b","repo":"tursodatabase/turso","slug":"encryption-is-not-supported-in-this-build-11b5c7","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/promise.ts","lineNumber":7,"sourceCode":"import { DatabasePromise, NativeDatabase, SqliteError, DatabaseOpts, EncryptionCipher, Transaction } 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 DatabasePromise {\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/promise.ts#L1-L25","documentation":"Same guard as the compat flavor, but in the native promise layer: getCipherValue() needs the native EncryptionCipher enum to translate cipher names, and throws when the loaded native addon does not export it. The lazy check exists so the error appears only when encryption is actually requested, at Database construction time. It signals the binary was built without encryption support.","triggerScenarios":"new Database(path, { encryptionKey, encryptionCipher }) in the promise flavor of @tursodatabase/database-native where NativeEncryptionCipher is undefined; version skew between the JS wrapper and the native addon; platforms whose prebuilt binary omits encryption.","commonSituations":"Lockfile pinning an old @tursodatabase/{platform} package while the wrapper expects the encryption enum; local debug builds of the NAPI addon; Docker images cached with stale native artifacts.","solutions":["Update @tursodatabase/native and matching platform binaries to an encryption-enabled build.","Rebuild the native module from source with encryption enabled if you self-host binaries.","Add a startup feature check on the EncryptionCipher import and fail with a clear message.","If you never intended encryption, remove encryptionKey/encryptionCipher options."],"exampleFix":"// before\nconst db = new Database('app.db', { encryptionKey, encryptionCipher: 'aegis256' }); // throws on builds without encryption\n\n// after\nimport { EncryptionCipher as Enc } from '#index';\nif (Enc == null) {\n  throw new Error('encryption unavailable in this native build; upgrade the native package');\n}\nconst db = new Database('app.db', { encryptionKey, encryptionCipher: 'aegis256' });","handlingStrategy":"type-guard","validationCode":"import { EncryptionCipher } from '#index';\nif (!EncryptionCipher) {\n  throw new Error('encryption unavailable in this native build; upgrade @tursodatabase/native');\n}\nconst db = new Database(path, { encryptionKey, encryptionCipher: 'aegis256' });","typeGuard":"const supportsEncryption = (enc: unknown): enc is object => enc != null;","tryCatchPattern":"try { const db = new Database(path, { encryptionKey, encryptionCipher }); } catch (e) { if (e instanceof Error && /Encryption is not supported in this build/.test(e.message)) { /* upgrade binary or open without encryption */ } else throw e; }","preventionTips":["Feature-detect EncryptionCipher at boot instead of discovering the gap at first open.","Refresh Docker/build caches after upgrading native addons to avoid stale binaries.","CI-test encrypted opens on every target platform."],"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"}