-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Prisma adapter: verification.delete() uses non-unique identifier in WhereUniqueInput #8313
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workinglockedLocked conversations after being closed for 7 daysLocked conversations after being closed for 7 days
Description
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
- Configure better-auth with Prisma adapter and email OTP plugin
- Trigger an OTP sign-in flow (
/api/auth/sign-in/email-otp) - 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
- Prisma adapter uses db[model].update with non‑unique where (AND …) → PrismaClientValidationError #5929 / fix(prisma-adapter): lift eq AND conditions to root so update detects unique where field #7096 — similar issue with
update()and compoundANDconditions (fixed, butdelete()path was not covered)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinglockedLocked conversations after being closed for 7 daysLocked conversations after being closed for 7 days