{"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/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/javascript/packages/native/compat.ts#L1-L25","documentation":"getCipherValue() in the native compat layer (bindings/javascript/packages/native/compat.ts:7) maps a cipher name like 'aes256gcm' to a native enum value; if the NAPI module's EncryptionCipher export is undefined it throws this error. That export is only present when the native binary was compiled with encryption support, so the throw means the loaded build simply does not contain the encryption feature. It fires as soon as you pass encryption options (cipher/key) that force cipher resolution.","triggerScenarios":"new Database(path, { cipher: 'aes256gcm', key }) (or any cipher option) with a native module built without the encryption feature; loading a prebuilt platform binary from a package variant that excludes encryption; a bundler/loader resolving '#index' to a stub or the wrong variant; version downgrade to a package whose binary lacked EncryptionCipher.","commonSituations":"Developing locally against a source build without encryption feature flags but shipping/accepting encrypted databases; mixing package variants (full vs. lite prebuilds) after an upgrade; optional-dependencies not installed so a fallback binary without encryption gets loaded; CI using a cached older binary.","solutions":["Install/use the package variant or prebuilt binary that includes encryption support (the one whose module exports EncryptionCipher).","If building from source, enable the encryption feature when compiling the native module, then rebuild/reinstall.","Remove cipher/key options if the database is not actually encrypted - the throw only happens when cipher resolution is requested.","Verify the loaded module at startup: inspect the EncryptionCipher export of the native index before constructing encrypted databases."],"exampleFix":"// before\nimport { Database } from \"@tursodatabase/database-native-compat\";\nconst db = new Database(\"file.db\", { cipher: \"aes256gcm\", key }); // build lacks encryption\n\n// after\nimport { Database } from \"@tursodatabase/database-native-compat\"; // package variant WITH encryption\nconst db = new Database(\"file.db\", { cipher: \"aes256gcm\", key });","handlingStrategy":"type-guard","validationCode":"import { EncryptionCipher } from \"#index\";\nconst encryptionSupported = EncryptionCipher != null;\nif (!encryptionSupported && opts.cipher) {\n  throw new Error(\"this native build lacks encryption; install the encryption-enabled variant\");\n}","typeGuard":"import { EncryptionCipher } from \"#index\";\nconst buildSupportsEncryption = (): boolean => EncryptionCipher != null;","tryCatchPattern":"try {\n  const db = new Database(path, { cipher, key });\n} catch (e) {\n  if (e instanceof Error && /Encryption is not supported/.test(e.message)) {\n    // fall back to an encryption-enabled build or reject encrypted databases early\n  } else throw e;\n}","preventionTips":["Check the EncryptionCipher export at startup before accepting encrypted-database configs.","Pin package variants whose prebuilds include encryption; clear caches after switching.","Gate encryption features behind a capability check so non-encryption builds degrade explicitly."],"tags":["encryption","native-build","cipher","feature-flag"],"backgroundTag":"feature-missing-from-build","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}