The field in where clause of the upsert query should be unique.

In this case, the email field is not unique due to which you are getting this error.

Updating schema file by adding @unique attribute to the email field will solve the issue.

model prismaUser {
  id           Int    @id @default(autoincrement())
  name         String @db.VarChar(255)
  email        String @unique @db.VarChar(255)
  profileViews Int
  role         String @db.VarChar(255)
}
Answer from Nurul Sundarani on Stack Overflow
🌐
GitHub
github.com › prisma › prisma › issues › 18183
Invalid `prisma.***.upsert()` invocation in ... · Issue #18183 · prisma/prisma
March 2, 2023 - bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.topic: $transaction([...])Sequential Prisma Client operationsSequential Prisma Client operationstopic: upsert() ... const { sub } = res.locals.user as User, [settings] = await prisma.$transaction([ prisma.settings.upsert({ where: { sub }, update: {}, create: { sub, darkMode: false }, }), ]);
Author   prisma
🌐
Onebite
onebite.dev › prisma-error-when-doing-upsert
Prisma error when doing upsert
February 3, 2023 - Request error PrismaClientValidationError: Invalid `prisma.user.upsert()` invocation: Unknown arg `column_name` in where.column_name for type UserWhereUniqueInput.
🌐
GitHub
github.com › prisma › prisma › issues › 5358
Invalid upsert invocation (P2014) in update scenario · Issue #5358 · prisma/prisma
January 30, 2021 - const data = { User: { connect: ... invocation: The change you are trying to make would violate the required relation 'PasswordResetAuthorizationToUser' between the `PasswordResetAuthorization` and `User` models....
Author   prisma
🌐
Linen
linen.dev › s › prisma › t › 2347461 › invalid-prisma-user-upsert-invocation-error-occurred-during-
```Invalid `prisma user upsert ` invocation Error occurred d Prisma #orm-help
August 15, 2022 - import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient({ log: ['query'], }); async function main() { const user = await prisma.$transaction([ prisma.users.upsert({ where: { id: '62fdeed1fd3ad81be5088625', }, create: { baraRequested: 1, isContribuitor: true, }, update: { baraRequested: 0, }, }), ]); console.log(user); } main() .catch((e) => { throw e; }) .finally(async () => { await prisma.$disconnect(); }); output:
🌐
GitHub
github.com › prisma › prisma › issues › 9781
Connect field upsert doesnt give target field error meta · Issue #9781 · prisma/prisma
October 14, 2021 - PrismaClientKnownRequestError: Invalid `prisma.user.upsert()` invocation: The required connected records were not found. Expected 1 records to be connected after connect operation on one-to-many relation 'CourseFeedbackToUser', found 0.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › discussions › 20127
Unique constraint failed on the (not available) · prisma/prisma · Discussion #20127
July 10, 2023 - Bug description It's showing - error PrismaClientKnownRequestError: Invalid prisma.user.upsert() invocation: Unique constraint failed on the (not available) on vercel logs when creating a new u...
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 25081
Concurrent `upsert` on MySQL results in Unique constraint error rather than one insert + one update · Issue #25081 · prisma/prisma
August 25, 2024 - FAIL ../test/cartridge.test.ts > /api/cartridge > post /api/cartridge - create a cartridge PrismaClientKnownRequestError: Invalid `prisma.user.upsert()` invocation: Unique constraint failed on the constraint: `users_email_key` ❯ _n.handleRequestError ../node_modules/.pnpm/@prisma+client@5.18.0_prisma@5.18.0/node_modules/@prisma/client/runtime/library.js:121:7749 ❯ _n.handleAndLogRequestError ../node_modules/.pnpm/@prisma+client@5.18.0_prisma@5.18.0/node_modules/@prisma/client/runtime/library.js:121:7057 ❯ _n.request ../node_modules/.pnpm/@prisma+client@5.18.0_prisma@5.18.0/node_modules/@
Author   prisma
Find elsewhere
🌐
GitHub
github.com › prisma › prisma › issues › 9751
Concurrent relation upserts conflict · Issue #9751 · prisma/prisma
October 13, 2021 - PrismaClientKnownRequestError3 [PrismaClientKnownRequestError]: Invalid `prisma.post.upsert()` invocation: Unique constraint failed on the fields: (`name`,`type`,`userId`) at cb (C:\PROJECTFOLDER\node_modules\@prisma\client\runtime\index.js:36063:17) at processTicksAndRejections (internal/...
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 12793
MongoDB: `upsert()` fails on `update` with relation when `notablescan: 1` · Issue #12793 · prisma/prisma
April 13, 2022 - Bug description Using MongoDB, the following error occurs when running an upsert and the document already exists: PrismaClientUnknownRequestError: Invalid `prisma.user.upsert()` invocation: Error occurred during query execution: Connecto...
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 26082
Upsert in transaction not working · Issue #26082 · prisma/prisma
January 13, 2025 - If you see this error, please, open an issue at https://pris.ly/prisma-prisma-bug-report`)}function Fe(e,t){throw new Error(t)}function Ti(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var Ri=(e,t)=>e.reduce((r,n)=>(r[t(n)]=n,r),{});function ht(e,t){let r={};for | ... truncated PrismaClientValidationError: Invalid `tx.actor.upsert()` invocation in /learn_activity_pub/src/services/authService.ts:94:36 91 92 console.log("Actor Data role", actorData.role); 93 → 94 const actor = await tx.actor.upsert({ where: { uri: "http://localhost:8000/users/user123" }, update: { userId: "cm5v4tjrw000
Author   prisma
🌐
Prisma
prisma.io › home › prisma client api › prisma client api › prisma client api
Prisma Client API | Prisma Documentation
INSERT INTO "public"."User" ("id","profileViews","userName","email") VALUES ($1,$2,$3,$4) ON CONFLICT ("userName") DO UPDATE SET "email" = $5 WHERE ("public"."User"."userName" = $6 AND 1=1) RETURNING "public"."User"."id", "public"."User"."profileViews", "public"."User"."userName", "public"."User"."email" The following query has multiple unique values in the where clause, so Prisma Client does not use a database upsert:
🌐
GitHub
github.com › prisma › prisma › discussions › 10524
Invalid `prisma.account.upsert()` invocation even though type system doesn't complain · prisma/prisma · Discussion #10524
November 30, 2021 - Invalid `prisma.account.upsert()` invocation: { include: { recipes: true, store: true, shopifySessions: true }, where: { email: 'name@example.com' }, create: { name: 'First last', email: 'name@example.com', store: { ~~~~~ connectOrCreate: { create: { createdAt: new Date('2021-12-01T05:29:35.097Z'), updatedAt: new Date('2021-12-01T05:29:35.097Z'), name: 'Product Store122', website: 'https://product-store122.myshopify.com', subdomain: 'productstore122myshopifycom', logoUrl: 'https://s3.amazonaws.com/....png', industryId: null, theme: {}, customerId: undefined, planId: '123', subscriptionId: unde
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 11469
Planetscale not able to upsert with Prisma · Issue #11469 · prisma/prisma
September 9, 2022 - Bug description It seems like the upsert command will yield HY000 code 1105 error. const response = await prisma.user.update({ data: { profile: { upsert: { update: { firstName: req.body.profile.firstName, lastName: req.body.profile.lastN...
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 21592
Update and read issues with `@prisma/adapter-planetscale` · Issue #21592 · prisma/prisma
October 23, 2023 - This error originated either by throwing inside an async function without a catch block or rejecting a promise not handled with .catch(). The promise was rejected with the reason: PrismaClientUnknownRequestError: Invalid `prismaClient.guild...
Author   prisma
🌐
Stack Overflow
stackoverflow.com › questions › 70656659 › invalid-prisma-create-invocation
mysql - invalid Prisma.create() invocation - Stack Overflow
From your console output, I can ... data.projectId which will return undefined. The error is complaining that you did not provide a valid argument inside the connect option (undefined is ignored by Prisma)....