PrismaClientValidationError:
Unanswered
Black imported fire ant posted this in #help-forum
Black imported fire antOP
can't find out why im getting this error only on deployment but its working good in local
Invalid `prisma.user.findUnique()` invocation:
{
where: {
id: undefined,
? email?: String,
? username?: String,
? stripeCustomerId?: String,
? AND?: UserWhereInput | UserWhereInput[],
? OR?: UserWhereInput[],
? NOT?: UserWhereInput | UserWhereInput[],
? createdAt?: DateTimeFilter | DateTime,
? updatedAt?: DateTimeFilter | DateTime,
? isPayed?: BoolFilter | Boolean,
? isJoined?: BoolFilter | Boolean
}
}
const user = await getUser();
// Check if a user with the given email already exists
const existingUser = await prisma.user.findUnique({
where: {
email: user?.email || "",
},
});
if (!existingUser) {
const new_user = await prisma.user.create({
data: {
email: user?.email,
isPayed: false,
isJoined: false,
// id: user?.id,
},
});
} else {
console.log("User already exists");
}
const currentUser =
existingUser ||
(await prisma.user.findUnique({
where: {
email: user?.email ?? "",
},
}));
23 Replies
In your local build, have you tested by passing "" as the email?
Because i assume thats the issue. Since findUnique work on atleast one field
Also is your email field marked @unique in your prisma schema?
Black imported fire antOP
yes its unique
im using an auth provider
Kinde it gives me error if im not using ""
Yeah so test by passing only ""
Black imported fire antOP
Type 'string | null | undefined' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
Also why are you using
`user?.email || ""
use user?.email ?? ""
Black imported fire antOP
hey i cannot pass email
Hence the error
Black imported fire antOP
im using discord auth so there is no user input to be done
ok
ill try
Your best bet is actually using a non-nullable field tbh.
Because technically
email: user?.email
should be fine. You shouldn't need the ?? OperatorBlack imported fire antOP
@Clown im still getting same error
btw what this mean
Argument `where` of type UserWhereUniqueInput needs at least one of `id`,
You need to pass id basically
I suppose its because its the only unique field which isnt optional
Black imported fire antOP
@Clown im confused why its working locally and not on server
also the code was working fine i was using vercel storage now i switched to planetscale and getting this error