[Better Auth]: unable_to_create_user #752

Closed
opened 2026-03-13 08:02:55 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @santosh-marar on GitHub (Feb 28, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

To reproduce issues

  1. Sign in with Google and Github

Current vs. Expected behavior

It has to be successfully user created but give this error
Argument emailVerified: Invalid value provided. Expected DateTime or Null, provided Boolean.
Argument type: String in account table
Argument provider: String in account table
Argument providerAccountId: String in account table

Don't know why in docs everything is fine but when generating schema through cli command then it give extra fields listed above which give error

What version of Better Auth are you using?

1.1.21

Provide environment information

- OS Ubuntu 24.04.2 LTS
- Browser almost tried in every major browser

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();
export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql", // or "mysql", "postgresql", ...etc
  }),
  socialProviders: {
    google: {
      clientId: process.env.GOOGLE_CLIENT_ID as string,
      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
    },
    github: {
      clientId: process.env.GITHUB_CLIENT_ID as string,
      clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
    },
  },
});

Additional context

2025-02-28T10:23:14.156Z ERROR [Better Auth]: PrismaClientValidationError:
Invalid db[getModelName(model)].create() invocation in
/home/santosh-marar/Documents/learning-2025/better-auth/.next/server/chunks/97437_better-auth_dist_d582f160._.js:7866:62

7863 if (!db[getModelName(model)]) {
7864 throw new TURBOPACK__imported__module$5b$project$5d2f$node_modules$2f2e$pnpm$2f$better$2d$auth$40$1$2e$1$2e$21$2f$node_modules$2f$better$2d$auth$2f$dist$2f$chunk$2d$UNWCXKMP$2e$js__$5b$app$2d$route$5d$$28$ecmascript$29$["BetterAuthError"](Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate');
7865 }
→ 7866 const result = await db[getModelName(model)].create({
data: {
id: "8WkJml1DbmGXIZmd6ufHJ7OcWI0Dds2T",
name: "Santosh Marar",
email: "st@gmail.com",
emailVerified: true,
~~~~
image: "https://lh3.googleusercontent.com/a/ACg8ocIvLvhiM_8_pjGOax1fE2yM9T3Cv59zduhbI7rJl9HkSvQxFyU=s96-c",
createdAt: new Date("2025-02-28T10:23:14.127Z"),
updatedAt: new Date("2025-02-28T10:23:14.127Z")
},
select: undefined
})

Argument emailVerified: Invalid value provided. Expected DateTime or Null, provided Boolean.
2025-02-28T10:23:14.157Z ERROR [Better Auth]: unable_to_create_user
GET /api/auth/callback/google?state=lbHYmR_vIYI5s0lta5qs6MswuBrOS23R&code=4%2F0AQSTgQEbiqhAxyL4zoVmumIcZyDtmkYzDpwIrngvEr93T6wLQ98S8u5MJTVm22zv9PLAHQ&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=1&prompt=none 302 in 1055ms

Originally created by @santosh-marar on GitHub (Feb 28, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce To reproduce issues 1. Sign in with Google and Github ### Current vs. Expected behavior It has to be successfully user created but give this error Argument `emailVerified`: Invalid value provided. Expected DateTime or Null, provided Boolean. Argument `type`: String in account table Argument `provider`: String in account table Argument `providerAccountId`: String in account table Don't know why in docs everything is fine but when generating schema through cli command then it give extra fields listed above which give error ### What version of Better Auth are you using? 1.1.21 ### Provide environment information ```bash - OS Ubuntu 24.04.2 LTS - Browser almost tried in every major browser ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { PrismaClient } from "@prisma/client"; const prisma = new PrismaClient(); export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", // or "mysql", "postgresql", ...etc }), socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID as string, clientSecret: process.env.GOOGLE_CLIENT_SECRET as string, }, github: { clientId: process.env.GITHUB_CLIENT_ID as string, clientSecret: process.env.GITHUB_CLIENT_SECRET as string, }, }, }); ``` ### Additional context 2025-02-28T10:23:14.156Z ERROR [Better Auth]: PrismaClientValidationError: Invalid `db[getModelName(model)].create()` invocation in /home/santosh-marar/Documents/learning-2025/better-auth/.next/server/chunks/97437_better-auth_dist_d582f160._.js:7866:62 7863 if (!db[getModelName(model)]) { 7864 throw new __TURBOPACK__imported__module__$5b$project$5d2f$node_modules$2f2e$pnpm$2f$better$2d$auth$40$1$2e$1$2e$21$2f$node_modules$2f$better$2d$auth$2f$dist$2f$chunk$2d$UNWCXKMP$2e$js__$5b$app$2d$route$5d$__$28$ecmascript$29$__["BetterAuthError"](`Model ${model} does not exist in the database. If you haven't generated the Prisma client, you need to run 'npx prisma generate'`); 7865 } → 7866 const result = await db[getModelName(model)].create({ data: { id: "8WkJml1DbmGXIZmd6ufHJ7OcWI0Dds2T", name: "Santosh Marar", email: "st@gmail.com", emailVerified: true, ~~~~ image: "https://lh3.googleusercontent.com/a/ACg8ocIvLvhiM_8_pjGOax1fE2yM9T3Cv59zduhbI7rJl9HkSvQxFyU=s96-c", createdAt: new Date("2025-02-28T10:23:14.127Z"), updatedAt: new Date("2025-02-28T10:23:14.127Z") }, select: undefined }) Argument `emailVerified`: Invalid value provided. Expected DateTime or Null, provided Boolean. 2025-02-28T10:23:14.157Z ERROR [Better Auth]: unable_to_create_user GET /api/auth/callback/google?state=lbHYmR_vIYI5s0lta5qs6MswuBrOS23R&code=4%2F0AQSTgQEbiqhAxyL4zoVmumIcZyDtmkYzDpwIrngvEr93T6wLQ98S8u5MJTVm22zv9PLAHQ&scope=email+profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile+openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email&authuser=1&prompt=none 302 in 1055ms
GiteaMirror added the bug label 2026-03-13 08:02:55 -05:00
Author
Owner

@moshetanzer commented on GitHub (Mar 23, 2025):

Hey,

It seems like db isnt generated (either not correclty or not genertated at all), take a look here https://www.better-auth.com/docs/concepts/database 😄

@moshetanzer commented on GitHub (Mar 23, 2025): Hey, It seems like db isnt generated (either not correclty or not genertated at all), take a look here https://www.better-auth.com/docs/concepts/database 😄
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#752