[Prisma Adapter] prisma.verification.create fails when generateId is false and strictUndefinedChecks is enabled #1384

Closed
opened 2026-03-13 08:36:13 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @yutakobayashidev on GitHub (Jun 19, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Set up the Prisma schema as shown below and enable strictUndefinedChecks.

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["strictUndefinedChecks"]
  output          = "../generated/prisma"
  moduleFormat    = "esm"
}

model Verification {
  id         String    @id @default(uuid(7))
  identifier String
  value      String
  expiresAt  DateTime
  createdAt  DateTime?
  updatedAt  DateTime?

  @@map("verification")
}

Set generateId to false and mount it to a Hono API.

import { env } from "@/env";
import { prisma } from "@/libs/prisma";
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";

export const auth = betterAuth({
  baseURL: env.BETTER_AUTH_URL,
  basePath: "/auth",
  trustedOrigins: [env.FRONTEND_BASE_URL],
  advanced: {
    crossSubDomainCookies: {
      enabled: true,
    },
    database: {
      generateId: false,
    },
  },
  account: {
    accountLinking: {
      enabled: true,
      trustedProviders: ["github"],
    },
  },
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  socialProviders: {
    github: {
      clientId: env.GITHUB_CLIENT_ID,
      clientSecret: env.GITHUB_CLIENT_SECRET,
    },
  },
  onAPIError: {
    onError(error) {
      console.error(error);
    },
  },
});

Current vs. Expected behavior

GitHub sign-in should succeed, and a new Verification record should be created without passing undefined as id.

prisma.verification.create({
  data: {
    identifier: "********", // masked
    value: "{\"callbackURL\":\"http://localhost:3000/****\",\"codeVerifier\":\"********\",\"expiresAt\":1750312273490}", // masked
    expiresAt: new Date("2025-06-19T05:51:13.490Z"),
    createdAt: new Date("2025-06-19T05:41:13.490Z"),
    updatedAt: new Date("2025-06-19T05:41:13.490Z"),
    id: undefined
           ~~~~~~~~~
  },
  select: undefined
})

Invalid value for argument `data`: explicitly `undefined` values are not allowed.

As a workaround, temporarily disable strictUndefinedChecks.

What version of Better Auth are you using?

Reproducible on 1.2.8 and later

Provide environment information

- OS: Ubuntu 
- Browser: Chrome

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

Backend

Additional context

https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/null-and-undefined

Originally created by @yutakobayashidev on GitHub (Jun 19, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce Set up the Prisma schema as shown below and enable `strictUndefinedChecks`. ```prisma generator client { provider = "prisma-client-js" previewFeatures = ["strictUndefinedChecks"] output = "../generated/prisma" moduleFormat = "esm" } model Verification { id String @id @default(uuid(7)) identifier String value String expiresAt DateTime createdAt DateTime? updatedAt DateTime? @@map("verification") } ```` Set generateId to false and mount it to a Hono API. ```ts import { env } from "@/env"; import { prisma } from "@/libs/prisma"; import { betterAuth } from "better-auth"; import { prismaAdapter } from "better-auth/adapters/prisma"; export const auth = betterAuth({ baseURL: env.BETTER_AUTH_URL, basePath: "/auth", trustedOrigins: [env.FRONTEND_BASE_URL], advanced: { crossSubDomainCookies: { enabled: true, }, database: { generateId: false, }, }, account: { accountLinking: { enabled: true, trustedProviders: ["github"], }, }, database: prismaAdapter(prisma, { provider: "postgresql", }), socialProviders: { github: { clientId: env.GITHUB_CLIENT_ID, clientSecret: env.GITHUB_CLIENT_SECRET, }, }, onAPIError: { onError(error) { console.error(error); }, }, }); ``` ### Current vs. Expected behavior GitHub sign-in should succeed, and a new Verification record should be created without passing undefined as id. ```bash prisma.verification.create({ data: { identifier: "********", // masked value: "{\"callbackURL\":\"http://localhost:3000/****\",\"codeVerifier\":\"********\",\"expiresAt\":1750312273490}", // masked expiresAt: new Date("2025-06-19T05:51:13.490Z"), createdAt: new Date("2025-06-19T05:41:13.490Z"), updatedAt: new Date("2025-06-19T05:41:13.490Z"), id: undefined ~~~~~~~~~ }, select: undefined }) Invalid value for argument `data`: explicitly `undefined` values are not allowed. ``` As a workaround, temporarily disable strictUndefinedChecks. ### What version of Better Auth are you using? Reproducible on 1.2.8 and later ### Provide environment information ```bash - OS: Ubuntu - Browser: Chrome ``` ### Which area(s) are affected? (Select all that apply) Backend ### Additional context https://www.prisma.io/docs/orm/prisma-client/special-fields-and-types/null-and-undefined
Author
Owner

@meness commented on GitHub (Aug 12, 2025):

I face the same exception when strictUndefinedChecks is enabled. To move forward, I disable strictUndefinedChecks for now

@meness commented on GitHub (Aug 12, 2025): I face the same exception when `strictUndefinedChecks` is enabled. To move forward, I disable `strictUndefinedChecks` for now
Author
Owner

@Jackman3005 commented on GitHub (Sep 1, 2025):

I ran into this issue, but then was able to switch to useNumberId for my situation instead, which did filter out id: undefined from the create call. However, I ran into the issue again when using the username() plugin. I didn't want to remove the feature as it would require a larger code change since the generated prisma client no longer has Prisma.skip. So I made a workaround, see this related issue I posted for the workaround. I think it's reasonably clean and simple, but definitely not ideal.

@Jackman3005 commented on GitHub (Sep 1, 2025): I ran into this issue, but then was able to switch to [`useNumberId`](https://www.better-auth.com/docs/reference/options#advanced) for my situation instead, which did filter out `id: undefined` from the create call. However, I ran into the issue again when using the `username()` plugin. I didn't want to remove the feature as it would require a larger code change since the generated prisma client no longer has `Prisma.skip`. So I made a workaround, see [this related issue](https://github.com/better-auth/better-auth/issues/4341) I posted for the workaround. I think it's reasonably clean and simple, but definitely not ideal.
Author
Owner

@dosubot[bot] commented on GitHub (Dec 1, 2025):

Hi, @yutakobayashidev. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported a failure in prisma.verification.create when using the Prisma adapter with generateId set to false and strictUndefinedChecks enabled, due to an undefined id being passed.
  • Other users, meness and Jackman3005, have confirmed the issue and shared temporary workarounds like disabling strictUndefinedChecks or using the useNumberId option.
  • The useNumberId workaround has complications, especially with the username() plugin.
  • A related issue with a proposed but imperfect workaround was referenced.
  • The core problem remains unresolved, impacting GitHub sign-in and Verification record creation.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of the better-auth repository by commenting here.
  • If I don’t hear back within 7 days, I will automatically close this issue.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Dec 1, 2025): Hi, @yutakobayashidev. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported a failure in `prisma.verification.create` when using the Prisma adapter with `generateId` set to false and `strictUndefinedChecks` enabled, due to an undefined `id` being passed. - Other users, meness and Jackman3005, have confirmed the issue and shared temporary workarounds like disabling `strictUndefinedChecks` or using the `useNumberId` option. - The `useNumberId` workaround has complications, especially with the `username()` plugin. - A related issue with a proposed but imperfect workaround was referenced. - The core problem remains unresolved, impacting GitHub sign-in and Verification record creation. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of the better-auth repository by commenting here. - If I don’t hear back within 7 days, I will automatically close this issue. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1384