[GH-ISSUE #364] LibsqlDialect doesn't work with encryptionKey option #16867

Closed
opened 2026-04-15 14:51:20 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @MurkyTheMurloc on GitHub (Oct 29, 2024).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/364

Describe the bug
When using better-auth with LibsqlDialect and enabling the encryptionKey option, an SQLITE_NOTADB error occurs. Disabling the encryptionKey option resolves the issue, but this disables encryption, which may be necessary in some use cases.

To Reproduce
Steps to reproduce the behavior:

  1. Configure better-auth to use a SQLite database.
  2. Set up LibsqlDialect with the following configuration:
    const dialect = new LibsqlDialect({
        url: "file:./auth/auth.db",
        syncUrl: process.env.TURSO_DATABASE_URL,
        authToken: process.env.TURSO_AUTH_TOKEN,
        syncInterval: 60,
        encryptionKey: process.env.ENCRYPTION_KEY,  // Enable encryption key
    });
    
  3. Attempt to call auth.api.signUpEmail()
  4. See error:
    {
      "code": "SQLITE_NOTADB",
      "rawCode": 26,
      "name": "LibsqlError"
    }
    
    

Expected behavior
The database should be accessed without errors when encryptionKey is specified.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS
  • Node.js version: 22.6.0
  • better-auth version: 0.6.2
  • SQLite version: latest

Smartphone (please complete the following information):
N/A

Additional context
The issue may relate to how better-auth interacts with SQLite encryption, or it may stem from a misconfiguration. Documentation or clarification on supported encryption setups would be helpful.

Originally created by @MurkyTheMurloc on GitHub (Oct 29, 2024). Original GitHub issue: https://github.com/better-auth/better-auth/issues/364 **Describe the bug** When using `better-auth` with `LibsqlDialect` and enabling the `encryptionKey` option, an `SQLITE_NOTADB` error occurs. Disabling the `encryptionKey` option resolves the issue, but this disables encryption, which may be necessary in some use cases. **To Reproduce** Steps to reproduce the behavior: 1. Configure `better-auth` to use a SQLite database. 2. Set up `LibsqlDialect` with the following configuration: ```javascript const dialect = new LibsqlDialect({ url: "file:./auth/auth.db", syncUrl: process.env.TURSO_DATABASE_URL, authToken: process.env.TURSO_AUTH_TOKEN, syncInterval: 60, encryptionKey: process.env.ENCRYPTION_KEY, // Enable encryption key }); 3. Attempt to call `auth.api.signUpEmail()` 4. See error: ```json { "code": "SQLITE_NOTADB", "rawCode": 26, "name": "LibsqlError" } **Expected behavior** The database should be accessed without errors when `encryptionKey` is specified. **Screenshots** N/A **Desktop (please complete the following information):** - OS: macOS - Node.js version: 22.6.0 - better-auth version: 0.6.2 - SQLite version: latest **Smartphone (please complete the following information):** N/A **Additional context** The issue may relate to how `better-auth` interacts with SQLite encryption, or it may stem from a misconfiguration. Documentation or clarification on supported encryption setups would be helpful.
GiteaMirror added the lockedbug labels 2026-04-15 14:51:20 -05:00
Author
Owner

@MurkyTheMurloc commented on GitHub (Oct 29, 2024):

const auth = betterAuth({
  emailAndPassword: {
    enabled: true,
  },
  database: {
    dialect: dialect,
    type: "sqlite",
  },
  plugins: [
    admin(),
    organization({
      ac: ac,
      roles: {
        member,
      },
    }),
  ],
});```
<!-- gh-comment-id:2444310121 --> @MurkyTheMurloc commented on GitHub (Oct 29, 2024): ```javascript const auth = betterAuth({ emailAndPassword: { enabled: true, }, database: { dialect: dialect, type: "sqlite", }, plugins: [ admin(), organization({ ac: ac, roles: { member, }, }), ], });```
Author
Owner

@Bekacru commented on GitHub (Dec 17, 2024):

We don’t have direct interaction with the underlying implementation of the LibSQL dialect for Kysely. I’m not sure if encryption requires a different configuration with Kysely, but if it does, feel free to open another issue mentioning that. But, this seems like a problem with the Kysely dialect itself rather than Better Auth. If the issue is due to misconfiguration on our end, feel free to open another issue.

<!-- gh-comment-id:2547837625 --> @Bekacru commented on GitHub (Dec 17, 2024): We don’t have direct interaction with the underlying implementation of the LibSQL dialect for Kysely. I’m not sure if encryption requires a different configuration with Kysely, but if it does, feel free to open another issue mentioning that. But, this seems like a problem with the Kysely dialect itself rather than Better Auth. If the issue is due to misconfiguration on our end, feel free to open another issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16867