[GH-ISSUE #8054] unable_to_create_user on Google OAuth using kysely-pglite-dialect #28304

Closed
opened 2026-04-17 19:44:07 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ajlende on GitHub (Feb 18, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8054

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Use the provided auth config on the server. It uses kysely-pglite-dialect and @electric-sql/pglite for the database and enables the Google social provider.
  2. Call authClient.signIn.social({ provider: "google" }) on the client.

Current vs. Expected behavior

I expect the user to be created, but I get this error instead.

2026-02-18T22:19:42.094Z ERROR [Better Auth]: unable_to_create_user
2026-02-18T22:19:50.332Z ERROR [Better Auth]: Error: Invalid input for boolean type

What version of Better Auth are you using?

1.4.18

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041",
    "release": "25.3.0",
    "cpuCount": 16,
    "cpuModel": "Apple M4 Max",
    "totalMemory": "48.00 GB",
    "freeMemory": "0.76 GB"
  },
  "node": {
    "version": "v24.12.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.29.3"
  },
  "frameworks": [
    {
      "name": "react",
      "version": "^19.2.3"
    }
  ],
  "databases": [
    {
      "name": "@electric-sql/pglite",
      "version": "^0.3.15"
    },
    {
      "name": "kysely",
      "version": "^0.28.10"
    },
    {
      "name": "kysely-pglite-dialect",
      "version": "^1.2.0"
    }
  ],
  "betterAuth": {
    "version": "^1.4.18",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
import { PGlite } from "@electric-sql/pglite"
import { PGliteDialect } from "kysely-pglite-dialect"

const client = new PGlite({
	dataDir: process.env.DATABASE_URL,
})

export const auth = betterAuth({
	database: { dialect: new PGliteDialect(client) },
	socialProviders: {
		google: {
			clientId: process.env.GOOGLE_CLIENT_ID as string,
			clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
		},
	},
})

Additional context

This could be caused by using 0 and 1 to represent true and false for boolean columns as PGlite doesn't do type coercion like Postgres does.

Originally created by @ajlende on GitHub (Feb 18, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8054 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Use the provided auth config on the server. It uses [kysely-pglite-dialect](https://www.npmjs.com/package/kysely-pglite-dialect) and [@electric-sql/pglite](https://www.npmjs.com/package/@electric-sql/pglite) for the database and enables the Google social provider. 2. Call `authClient.signIn.social({ provider: "google" })` on the client. ### Current vs. Expected behavior I expect the user to be created, but I get this error instead. ``` 2026-02-18T22:19:42.094Z ERROR [Better Auth]: unable_to_create_user 2026-02-18T22:19:50.332Z ERROR [Better Auth]: Error: Invalid input for boolean type ``` ### What version of Better Auth are you using? 1.4.18 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.3.0: Wed Jan 28 20:48:41 PST 2026; root:xnu-12377.81.4~5/RELEASE_ARM64_T6041", "release": "25.3.0", "cpuCount": 16, "cpuModel": "Apple M4 Max", "totalMemory": "48.00 GB", "freeMemory": "0.76 GB" }, "node": { "version": "v24.12.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.29.3" }, "frameworks": [ { "name": "react", "version": "^19.2.3" } ], "databases": [ { "name": "@electric-sql/pglite", "version": "^0.3.15" }, { "name": "kysely", "version": "^0.28.10" }, { "name": "kysely-pglite-dialect", "version": "^1.2.0" } ], "betterAuth": { "version": "^1.4.18", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { PGlite } from "@electric-sql/pglite" import { PGliteDialect } from "kysely-pglite-dialect" const client = new PGlite({ dataDir: process.env.DATABASE_URL, }) export const auth = betterAuth({ database: { dialect: new PGliteDialect(client) }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, }, }) ``` ### Additional context This could be caused by using `0` and `1` to represent `true` and `false` for `boolean` columns as PGlite doesn't do type coercion like Postgres does.
GiteaMirror added the lockedbug labels 2026-04-17 19:44:07 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Feb 18, 2026):

Hi @ajlende! I'm Dosu and I’m helping the better-auth team.

The issue is that you're passing the dialect directly to the database config without specifying the database type. When the type isn't specified, Better Auth defaults to treating booleans as unsupported, which causes type mismatches with PGlite.

Fix: Use the Kysely adapter explicitly with type: "postgres":

import { betterAuth } from "better-auth"
import { kyselyAdapter } from "better-auth/adapters/kysely"
import { Kysely } from "kysely"
import { PGlite } from "@electric-sql/pglite"
import { PGliteDialect } from "kysely-pglite-dialect"

const client = new PGlite({
  dataDir: process.env.DATABASE_URL,
})

const db = new Kysely({
  dialect: new PGliteDialect(client),
})

export const auth = betterAuth({
  database: kyselyAdapter(db, {
    type: "postgres", // This enables proper boolean handling
  }),
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
    },
  },
})

Setting type: "postgres" tells Better Auth that PGlite supports native boolean types, so it won't try to convert true/false to 0/1.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3923624092 --> @dosubot[bot] commented on GitHub (Feb 18, 2026): <!-- Greeting --> Hi @ajlende! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The issue is that you're passing the dialect directly to the `database` config without specifying the database type. When the type isn't specified, [Better Auth defaults to treating booleans as unsupported](https://github.com/better-auth/better-auth/blob/07d80082fce33871f543f5d5191cfbf0b22adb21/packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts#L617-L621), which causes type mismatches with PGlite. **Fix:** Use the Kysely adapter explicitly with `type: "postgres"`: ```typescript import { betterAuth } from "better-auth" import { kyselyAdapter } from "better-auth/adapters/kysely" import { Kysely } from "kysely" import { PGlite } from "@electric-sql/pglite" import { PGliteDialect } from "kysely-pglite-dialect" const client = new PGlite({ dataDir: process.env.DATABASE_URL, }) const db = new Kysely({ dialect: new PGliteDialect(client), }) export const auth = betterAuth({ database: kyselyAdapter(db, { type: "postgres", // This enables proper boolean handling }), socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, }, }) ``` Setting `type: "postgres"` tells Better Auth that PGlite supports native boolean types, so it won't try to convert `true`/`false` to `0`/`1`. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/5a5a00c7-88ce-4f1e-8180-3ed84ba25ed4?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5a5a00c7-88ce-4f1e-8180-3ed84ba25ed4?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5a5a00c7-88ce-4f1e-8180-3ed84ba25ed4?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5a5a00c7-88ce-4f1e-8180-3ed84ba25ed4?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5a5a00c7-88ce-4f1e-8180-3ed84ba25ed4?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5a5a00c7-88ce-4f1e-8180-3ed84ba25ed4?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5a5a00c7-88ce-4f1e-8180-3ed84ba25ed4?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20issue%20is%20that%20you%27re%20passing%20the%20dialect%20directly%20to%20the%20%60database%60%20config%20without%20specifying%20the%20database%20type.%20When%20the%20type%20isn%27t%20specified%2C%20%5BBetter%20Auth%20defaults%20to%20treating%20booleans%20as%20unsupported%5D%28https%3A//github.com/better-auth/better-auth/blob/07d80082fce33871f543f5d5191cfbf0b22adb21/packages/better-auth/src/adapters/kysely-adapter/kysely-adapter.ts%23L617-L621%29%2C%20which%20causes%20type%20mismatches%20with%20PGlite.%0A%0A%2A%2AFix%3A%2A%2A%20Use%20the%20Kysely%20adapter%20explicitly%20with%20%60type%3A%20%22postgres%22%60%3A%0A%0A%60%60%60typescript%0Aimport%20%7B%20betterAuth%20%7D%20from%20%22better-auth%22%0Aimport%20%7B%20kyselyAdapter%20%7D%20from%20%22better-auth/adapters/kysely%22%0Aimport%20%7B%20Kysely%20%7D%20from%20%22kysely%22%0Aimport%20%7B%20PGlite%20%7D%20from%20%22%40electric-sql/pglite%22%0Aimport%20%7B%20PGliteDialect%20%7D%20from%20%22kysely-pglite-dialect%22%0A%0Aconst%20client%20%3D%20new%20PGlite%28%7B%0A%20%20dataDir%3A%20process.env.DATABASE_URL%2C%0A%7D%29%0A%0Aconst%20db%20%3D%20new%20Kysely%28%7B%0A%20%20dialect%3A%20new%20PGliteDialect%28client%29%2C%0A%7D%29%0A%0Aexport%20const%20auth%20%3D%20betterAuth%28%7B%0A%20%20database%3A%20kyselyAdapter%28db%2C%20%7B%0A%20%20%20%20type%3A%20%22postgres%22%2C%20//%20This%20enables%20proper%20boolean%20handling%0A%20%20%7D%29%2C%0A%20%20socialProviders%3A%20%7B%0A%20%20%20%20google%3A%20%7B%0A%20%20%20%20%20%20clientId%3A%20process.env.GOOGLE_CLIENT_ID%20as%20string%2C%0A%20%20%20%20%20%20clientSecret%3A%20process.env.GOOGLE_CLIENT_SECRET%20as%20string%2C%0A%20%20%20%20%7D%2C%0A%20%20%7D%2C%0A%7D%29%0A%60%60%60%0A%0ASetting%20%60type%3A%20%22postgres%22%60%20tells%20Better%20Auth%20that%20PGlite%20supports%20native%20boolean%20types%2C%20so%20it%20won%27t%20try%20to%20convert%20%60true%60/%60false%60%20to%20%600%60/%601%60.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/8054)
Author
Owner

@ajlende commented on GitHub (Feb 18, 2026):

@dosu's example was incorrect, but adding type: "postgres" along with the dialect fixed it.

<!-- gh-comment-id:3923653444 --> @ajlende commented on GitHub (Feb 18, 2026): @dosu's example was incorrect, but adding `type: "postgres"` along with the `dialect` fixed it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28304