[GH-ISSUE #3469] PrismaClientValidationError: emailVerified expects DateTime or null, but receives boolean (false) on user signup #9615

Closed
opened 2026-04-13 05:10:29 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @mriusero on GitHub (Jul 19, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3469

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Set up a Next.js backend with Prisma and PostgreSQL using the following versions:

    • Next.js: 15.3.5
    • Prisma: 6.12.0
    • @prisma/client: 6.12.0
    • Node.js: 23.11.0
    • PostgreSQL: 17.4
    • BetterAuth: 1.2.12
  2. Use the following Prisma schema for the user model in schema.prisma:

model User {
  id            String          @id @default(cuid())
  name          String?
  email         String          @unique
  emailVerified DateTime?
  image         String?
  accounts      Account[]
  sessions      Session[]
  // Optional for WebAuthn support
  Authenticator Authenticator[]
  createdAt     DateTime        @default(now())
  updatedAt     DateTime        @updatedAt

  @@map("user")
}
  1. Integrate BetterAuth in your backend in lib/auth.ts:
    import { betterAuth } from 'better-auth'
    import { prismaAdapter } from 'better-auth/adapters/prisma'
    import { prisma } from "@/lib/prisma"
    
    export const auth = betterAuth({
      database: prismaAdapter(prisma, {
        provider: 'postgresql',
      }),
      emailAndPassword: {
        enabled: true,
      },
      socialProviders: {
        github: {
          clientId: process.env.GITHUB_CLIENT_ID,
          clientSecret: process.env.GITHUB_CLIENT_SECRET,
        },
      },
      trustedOrigins: ['http://localhost:3000'],
    })
    
  2. Define AuthClient in auth-client.ts:
import { createAuthClient } from "better-auth/react"
export const authClient = createAuthClient({
    baseURL: "http://localhost:3000"
})
  1. Use BetterAuth client:
const result = await authClient.signUp.email({ name, email, password });
  1. Attempt to sign up a new user.

Current vs. Expected behavior

  • Current:
    Signup fails with the following error:

    PrismaClientValidationError: 
    Invalid `prisma.user.create()` invocation:
    Argument `emailVerified`: Invalid value provided. Expected DateTime or Null, provided Boolean.
    

    The value emailVerified: false is passed to Prisma, which is not valid for a DateTime? field.

  • Expected:
    On signup, if the email is not verified, emailVerified should be set to null (not false). If the email is verified, it should be set to a valid DateTime.

What version of Better Auth are you using?

  • better-auth: 1.2.12

Provide environment information

- Next.js: 15.3.5
- Prisma: 6.12.0
- @prisma/client: 6.12.0
- Node.js: 23.11.0
- PostgreSQL: 17.4
- OS: macOS (darwin-arm64)

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

Backend, Package, Documentation

Auth config (if applicable)

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: 'postgresql',
  }),
  emailAndPassword: {
    enabled: true,
  },
  socialProviders: {
    github: {
      clientId: process.env.GITHUB_CLIENT_ID,
      clientSecret: process.env.GITHUB_CLIENT_SECRET,
    },
  },
  trustedOrigins: ['http://localhost:3000'],
})

Additional context

  • The database is empty and freshly migrated.
  • The bug is reproducible locally.
  • No legacy data from previous auth systems.
  • The error occurs on every signup attempt.
Originally created by @mriusero on GitHub (Jul 19, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3469 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Set up a Next.js backend with Prisma and PostgreSQL using the following versions: - Next.js: 15.3.5 - Prisma: 6.12.0 - @prisma/client: 6.12.0 - Node.js: 23.11.0 - PostgreSQL: 17.4 - BetterAuth: 1.2.12 2. Use the following Prisma schema for the user model in `schema.prisma`: ```prisma model User { id String @id @default(cuid()) name String? email String @unique emailVerified DateTime? image String? accounts Account[] sessions Session[] // Optional for WebAuthn support Authenticator Authenticator[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@map("user") } ``` 3. Integrate BetterAuth in your backend in `lib/auth.ts`: ```js import { betterAuth } from 'better-auth' import { prismaAdapter } from 'better-auth/adapters/prisma' import { prisma } from "@/lib/prisma" export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: 'postgresql', }), emailAndPassword: { enabled: true, }, socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID, clientSecret: process.env.GITHUB_CLIENT_SECRET, }, }, trustedOrigins: ['http://localhost:3000'], }) ``` 4. Define AuthClient in `auth-client.ts`: ```js import { createAuthClient } from "better-auth/react" export const authClient = createAuthClient({ baseURL: "http://localhost:3000" }) ``` 5. Use BetterAuth client: ```js const result = await authClient.signUp.email({ name, email, password }); ``` 6. Attempt to sign up a new user. ### Current vs. Expected behavior - **Current:** Signup fails with the following error: ``` PrismaClientValidationError: Invalid `prisma.user.create()` invocation: Argument `emailVerified`: Invalid value provided. Expected DateTime or Null, provided Boolean. ``` The value `emailVerified: false` is passed to Prisma, which is not valid for a `DateTime?` field. - **Expected:** On signup, if the email is not verified, `emailVerified` should be set to `null` (not `false`). If the email is verified, it should be set to a valid `DateTime`. ### What version of Better Auth are you using? - better-auth: 1.2.12 ### Provide environment information ```bash - Next.js: 15.3.5 - Prisma: 6.12.0 - @prisma/client: 6.12.0 - Node.js: 23.11.0 - PostgreSQL: 17.4 - OS: macOS (darwin-arm64) ``` ### Which area(s) are affected? (Select all that apply) Backend, Package, Documentation ### Auth config (if applicable) ```typescript export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: 'postgresql', }), emailAndPassword: { enabled: true, }, socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID, clientSecret: process.env.GITHUB_CLIENT_SECRET, }, }, trustedOrigins: ['http://localhost:3000'], }) ``` ### Additional context - The database is empty and freshly migrated. - The bug is reproducible locally. - No legacy data from previous auth systems. - The error occurs on every signup attempt.
GiteaMirror added the lockedbug labels 2026-04-13 05:10:29 -05:00
Author
Owner

@frectonz commented on GitHub (Sep 4, 2025):

Unfortunately this is currently unplanned. By setting emailVerified to DateTime you are violating the invariant Better Auth is built on. Better Auth expects emailVerified column to be a boolean. We might consider this in the future but this is currently unsupported.

<!-- gh-comment-id:3254266283 --> @frectonz commented on GitHub (Sep 4, 2025): Unfortunately this is currently unplanned. By setting `emailVerified` to `DateTime` you are violating the invariant Better Auth is built on. Better Auth expects `emailVerified` column to be a `boolean`. We might consider this in the future but this is currently unsupported.
Author
Owner

@mriusero commented on GitHub (Sep 4, 2025):

No problem, that's what I discovered when I tried to solve it and I understand perfectly, thanks for the answer !

<!-- gh-comment-id:3255042492 --> @mriusero commented on GitHub (Sep 4, 2025): No problem, that's what I discovered when I tried to solve it and I understand perfectly, thanks for the answer !
Author
Owner

@himself65 commented on GitHub (Sep 5, 2025):

I think you can manually add a extra field on the db and add hook for the email verify endpoint

<!-- gh-comment-id:3257011601 --> @himself65 commented on GitHub (Sep 5, 2025): I think you can manually add a extra field on the db and add hook for the email verify endpoint
Author
Owner

@doinghun commented on GitHub (Oct 21, 2025):

User Schema
Map the following fields in the user schema:

  • (next-auth v4) emailVerified: datetime → boolean

The documentation mentions above for migration from nextauth.js to better auth.

What does this mean? what is the recommended workaround?

<!-- gh-comment-id:3427017134 --> @doinghun commented on GitHub (Oct 21, 2025): > [User Schema](https://www.better-auth.com/docs/guides/next-auth-migration-guide#user-schema) > Map the following fields in the user schema: > - (next-auth v4) emailVerified: datetime → boolean The [documentation](https://www.better-auth.com/docs/guides/next-auth-migration-guide#user-schema) mentions above for migration from nextauth.js to better auth. What does this mean? what is the recommended workaround?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#9615