Skip to content

Prisma adapter: verification.delete() uses non-unique identifier in WhereUniqueInput #8313

@aniravi24

Description

@aniravi24

Bug Report

Description

The Prisma adapter calls prisma.verification.delete({ where: { identifier } }) during the email OTP sign-in flow, but identifier is not a unique field on the verification table. Prisma's delete() requires a WhereUniqueInput, so it rejects the call.

This is a different code path from the fix in #7096 (which addressed compound AND conditions in update()). Here the issue is that delete() is used with a plain non-unique field.

Environment

  • better-auth version: 1.5.1
  • Prisma version: 7.4.2
  • Database: PostgreSQL
  • Node runtime: Bun

Steps to Reproduce

  1. Configure better-auth with Prisma adapter and email OTP plugin
  2. Trigger an OTP sign-in flow (/api/auth/sign-in/email-otp)
  3. The adapter attempts to clean up old verification records by identifier

Error

PrismaClientValidationError:
Invalid `prisma.verification.delete()` invocation:

{
  where: {
    identifier: "sign-in-otp-user@example.com",
?   id?: String,
?   AND?: VerificationWhereInput | VerificationWhereInput[],
?   OR?: VerificationWhereInput[],
?   NOT?: VerificationWhereInput | VerificationWhereInput[],
?   value?: StringFilter | String,
?   expiresAt?: DateTimeFilter | DateTime,
?   createdAt?: DateTimeFilter | DateTime,
?   updatedAt?: DateTimeNullableFilter | DateTime | Null
  }
}

Argument `where` of type VerificationWhereUniqueInput needs at least one of `id` arguments.

Expected Behavior

The adapter should use deleteMany({ where: { identifier } }) instead of delete({ where: { identifier } }), since identifier is not a unique field in better-auth's own schema definition (it only has a regular index, not a unique constraint).

Related

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglockedLocked conversations after being closed for 7 days

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions