PrismaClientValidationError:
Unanswered
Black imported fire ant posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
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
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
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?
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Black imported fire antOP
yes its unique
im using an auth provider
Kinde it gives me error if im not using ""
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Yeah so test by passing only ""
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
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'.
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Also why are you using
`user?.email || ""
use user?.email ?? ""
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Black imported fire antOP
hey i cannot pass email
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Hence the error
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Black imported fire antOP
im using discord auth so there is no user input to be done
ok
ill try
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Your best bet is actually using a non-nullable field tbh.
Because technically
email: user?.email
should be fine. You shouldn't need the ?? Operator![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Black imported fire antOP
@Clown im still getting same error
btw what this mean
Argument `where` of type UserWhereUniqueInput needs at least one of `id`,
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
You need to pass id basically
I suppose its because its the only unique field which isnt optional
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
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