Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in Prisma Client request #1195

Closed
silverbucket opened this issue Dec 16, 2023 · 38 comments
Closed

Error in Prisma Client request #1195

silverbucket opened this issue Dec 16, 2023 · 38 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: "Prisma Client Error"

Comments

@silverbucket
Copy link

silverbucket commented Dec 16, 2023

Bug description

Simply start up prisma studio, after a few seconds the browser gives the error:

[runQuery] Error in Prisma Client request: 


Invalid `f=e.match(J2t)?.[1]??"",g=e.match(Q2t)?.[1]??null,v=e.match(Z2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(`${c.prismaClient}/runtime/${u}`),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,GN.createHash)("sha256").update()` invocation in
/Users/njenning/code/projects/word-of-the-day/node_modules/.pnpm/prisma@5.7.0/node_modules/prisma/build/index.js:1521:12640

  1518 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}else return on(`Accelerate enabled. Use your secure API key in your Accelerate connection string to authenticate requests.
  1519 
  1520 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}};var zR={};da(zR,{$:()=>GR,Create:()=>VR,Delete:()=>HR,Show:()=>WR});var GR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var VR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project,"--name":String,"-n":"--name"});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=Co(n,["--name","-n"]),c=await fr({token:i,path:`/${a}/${o}/settings/api-keys/create`,route:"_app.$organizationId_.$projectId.settings.api-keys.create",payload:{displayName:u}});if(c.error?.message)throw new Error(c.error.message);return on(`New API Key created: ${c.data.tenantAPIKey}`)}};var HR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project,"--apikey":String});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=Gt(n,["--apikey"]);if(ee(u))return u;let c=await fr({token:i,path:`/${a}/${o}/settings/api-keys`,route:"_app.$organizationId_.$projectId.settings.api-keys",payload:{id:u}});if(c.error?.message)throw new Error(c.error.message);return on(`API Key ${c.data.displayName} deleted.`)}};var WR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=await fr({token:i,path:`/${a}/${o}/settings/api-keys`,route:"_app.$organizationId_.$projectId.settings.api-keys"});return console.table(u.serviceKeys.map(({id:c,displayName:p,createdAt:l})=>({id:c,createdAt:l,name:p})),["id","name","createdAt"]),""}};var XR={};da(XR,{$:()=>KR,Login:()=>$5,Logout:()=>q5,Show:()=>YR});var KR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var g2e=L(h2e()),v2e=L(v0()),y2e=L(require("http"));var b2e=L(Q3()),M5=L(Bf());var x2e=ue("prisma:cli:platform:login"),$5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;if(r.token)return`Already authenticated. Run ${Y(Ee("prisma platform auth show --early-access"))} to see the current user.`;console.info("Authenticating to Prisma Platform CLI via browser");let n=y2e.default.createServer(),i=await(0,g2e.default)(n,0,"127.0.0.1"),a=await llt({connection:"github",redirectTo:i.href});console.info("Visit the following URL in your browser to authenticate:"),console.info(ye(a.href));try{let[o]=await Promise.all([new Promise((c,p)=>{n.once("request",(l,f)=>{n.close(),f.setHeader("connection","close");let g=new URL(l.url||"/","http://localhost").searchParams,v=g.get("token")??"",E=g.get("error"),x=new URL("/auth/cli",$R);if(E)x.pathname+="/error",x.searchParams.set("error",E),p(new Error(E));else{let S=flt(g.get("user")??"");if(S){g.delete("token"),g.delete("user"),x.pathname+="/success";let C=new URLSearchParams({...Object.fromEntries(g.entries()),email:S.email});x.search=C.toString(),c({token:v,user:S})}else x.pathname+="/error",x.searchParams.set("error","Invalid user"),p(new Error("Invalid user"))}f.statusCode=302,f.setHeader("location",x.href),f.end()}),n.once("error",p)}),(0,b2e.default)(a.href)]),u=await d2e({token:o.token});if(ee(u))throw u;return on(`Authentication successful for ${o.user.email}`)}catch(o){throw new Error(`Authentication failed: ${ee(o)?o.message:""}`)}}},llt=async e=>{let r=await v2e.getSignature().catch(o=>(x2e(`await checkpoint.getSignature() failed silently with ${o}`),null)),n={client:`${M5.name}@${M5.version}`,signature:r,...e},i=Buffer.from(JSON.stringify(n),"utf-8").toString("base64"),a=new URL("/auth/cli",$R);return a.searchParams.set("state",i),a},dlt=e=>{if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.id=="string"&&typeof r.displayName=="string"&&typeof r.handle=="string"&&typeof r.email=="string"},flt=e=>{try{let r=JSON.parse(Buffer.from(e,"base64").toString("utf-8"));return dlt(r)?r:null}catch(r){return x2e(`parseUser() failed silently with ${r}`),null}};var q5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;return r.token?(await f2e(),on("You have logged out")):`You are not currently logged in. Run ${Y(Ee("prisma platform auth login --early-access"))} to log in.`}};var YR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.global});if(ee(n))return n;let i=await Cr(n),a=await fr({token:i,path:"/settings/account",route:"_app._user.settings.account"});return console.info(`Currently authenticated as ${Y(a.user.email)}
→ 1521 `),Cc([["id",a.user.id],["handle",a.user.handle],["email",a.user.email],["displayName",a.user.displayName]])}};var tI={};da(tI,{$:()=>JR,Create:()=>QR,Delete:()=>ZR,Show:()=>eI});var JR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var QR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.workspace,"--name":String,"-n":"--name"});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Co(n,["--name","-n"]),u=await fr({token:i,path:`/${a}/overview/create`,route:"_app.$organizationId.overview.create",payload:{displayName:o}});if(u.error)throw new Error(`${u.error.name}: ${u.error.message}`);return on(`Project ${u.data.displayName} - ${u.data.id} created.`)}};var ZR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=await fr({token:i,path:`/${a}/${o}/settings/general`,route:"_app.$organizationId_.$projectId.settings.general",payload:{intent:"delete"}});if(u.error)throw new Error(`${u.error.name}: ${u.error.message}`);return on(`Project ${u.data.displayName} - ${u.data.id} deleted.`)}};var eI=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.workspace});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=await fr({token:i,path:`/${a}/overview`,route:"_app.$organizationId.overview"});return console.table(o.organization.projects.map(({id:u,displayName:c,createdAt:p})=>({id:u,createdAt:p,name:c})),["id","name","createdAt"]),""}};var iI={};da(iI,{$:()=>rI,Show:()=>nI});var rI=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var nI=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.global});if(ee(n))return n;let i=await Cr(n),a=await fr({token:i,path:"/settings/workspaces",route:"_app._user.settings.workspaces"});return console.table(a.organizations.map(o=>({id:o.id,name:o.displayName,createdAt:o.createdAt})),["id","name","createdAt"]),""}};var K8e=require("@prisma/engines");var w2e=require("buffer");function E2e(e,r,n,i){Object.defineProperty(e,r,{get:n,set:i,enumerable:!0,configurable:!0})}var _2e={};E2e(_2e,"serializeRPCMessage",()=>oI);E2e(_2e,"deserializeRPCMessage",()=>uI);var aI="PrismaBigInt::",sI="PrismaBytes::";function oI(e){return JSON.stringify(e,(r,n)=>typeof n=="bigint"?aI+n:n?.type==="Buffer"&&Array.isArray(n?.data)?sI+w2e.Buffer.from(n.data).toString("base64"):n)}function uI(e){return JSON.parse(e,(r,n)=>typeof n=="string"&&n.startsWith(aI)?BigInt(n.substr(aI.length)):typeof n=="string"&&n.startsWith(sI)?n.substr(sI.length):n)}var q8e=L(O2e()),O9=L(w8e()),j8e=L(require("http")),B8e=L(S8e()),U8e=require("zlib");var Ns=require("path");var GN=require("crypto"),O8e=L(qN());function A9(e,r,n,i){Object.defineProperty(e,r,{get:n,set:i,enumerable:!0,configurable:!0})}var R8e=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{},jN={},P9={},Ma=R8e.parcelRequire1308;Ma==null&&(Ma=function(e){if(e in jN)return jN[e].exports;if(e in P9){var r=P9[e];delete P9[e];var n={id:e,exports:{}};return jN[e]=n,r.call(n.exports,n,n.exports),n.exports}var i=new Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i},Ma.register=function(r,n){P9[r]=n},R8e.parcelRequire1308=Ma);Ma.register("9lTzd",function(module,exports){A9(module.exports,"guessEnginePaths",()=>guessEnginePaths),A9(module.exports,"guessPrismaClientPath",()=>guessPrismaClientPath);var $5COlq=Ma("5COlq");async function guessEnginePaths({forceBinary,forceLibrary,resolveOverrides}){let queryEngineName,queryEngineType;if(forceLibrary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","library"),queryEngineType="library"):forceBinary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","binary"),queryEngineType="binary"):(queryEngineName=void 0,queryEngineType=void 0),!queryEngineName||!queryEngineType)return{queryEngine:void 0};let queryEnginePath;if(resolveOverrides[".prisma/client"])queryEnginePath=(0,Ns.resolve)(resolveOverrides[".prisma/client"],`../${queryEngineName}`);else if(resolveOverrides["@prisma/engines"])queryEnginePath=(0,Ns.resolve)(resolveOverrides["@prisma/engines"],`../../${queryEngineName}`);else{let atPrismaEnginesPath;try{atPrismaEnginesPath=eval("require.resolve('@prisma/engines')")}catch(e){throw new Error("Unable to resolve Prisma engine paths. This is a bug.")}queryEnginePath=(0,Ns.resolve)(atPrismaEnginesPath`../../${queryEngineName}`)}return{queryEngine:{type:queryEngineType,path:queryEnginePath}}}function guessPrismaClientPath({resolveOverrides}){let prismaClientPath=resolveOverrides["@prisma/client"]||eval("require.resolve('@prisma/client')");return(0,Ns.resolve)(prismaClientPath,"../")}});Ma.register("5COlq",function(e,r){A9(e.exports,"prismaEngineName",()=>i);var n=Ma("1dWWL");async function i(a,o){let u=await n.getPlatform(),c=u==="windows"?".exe":"";if(o==="library")return qa(u,"fs");if(o==="binary")return`${a}-${u}${c}`;throw new Error(`Unknown engine type: ${o}`)}});Ma.register("1dWWL",function(e,r){A9(e.exports,"getPlatform",()=>i);let n;async function i(){return n||(n=await hr(),n)}});function X2t(e){return{models:BN(e.models),enums:BN(e.enums),types:BN(e.types)}}function BN(e){let r={};for(let{name:n,...i}of e)r[n]=i;return r}var Y2=(0,O8e.debug)("prisma:studio-pcw"),J2t=/^\s*datasource\s+([^\s]+)\s*{/m,Q2t=/url *= *env\("(.*)"\)/,Z2t=/url *= *"(.*)"/;async function egt({schema:e,schemaPath:r,dmmf:n,datasourceProvider:i,previewFeatures:a,datasources:o,engineType:u,paths:c,directUrl:p,versions:l}){let f=e.match(J2t)?.[1]??"",g=e.match(Q2t)?.[1]??null,v=e.match(Z2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(`${c.prismaClient}/runtime/${u}`),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,GN.createHash)("sha256").update(
Raw query failed. Code: `unknown`. Message: `Kind: Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: localhost:27017, Type: Unknown, Error: Kind: I/O error: unexpected end of file, labels: {} } ] }, labels: {}`

How to reproduce

  1. pnpx prisma studio
  2. Brower window loads, tries to fetch data
  3. Popup "Prisma Client Error" Unable to run script

Expected behavior

Should load the database table.

Prisma information

// Add your schema.prisma
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

enum Language {
  CZECH
  ENGLISH
}

model Word {
  id               String   @id @default(auto()) @map("_id") @db.ObjectId
  lang             Language
  name             String
  image            String
  translatesTo     Word[]   @relation("WordTranslations", fields: [translatesToId], references: [id])
  translatesToId   String[] @db.ObjectId
  translatesFrom   Word[]   @relation("WordTranslations", fields: [translatesFromId], references: [id])
  translatesFromId String[] @db.ObjectId
  definition       String
  sentence         String
}
// Add your code using Prisma Client

Environment & setup

  • OS: macOs
  • Database: MongoDB
  • Node.js version: v18.70.0

Prisma Version

npx prisma -v
Environment variables loaded from .env
prisma                  : 5.7.0
@prisma/client          : 5.7.0
Computed binaryTarget   : darwin-arm64
Operating System        : darwin
Architecture            : arm64
Node.js                 : v18.17.0
Query Engine (Node-API) : libquery-engine 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9 (at node_modules/.pnpm/@prisma+engines@5.7.0/node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine           : schema-engine-cli 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9 (at node_modules/.pnpm/@prisma+engines@5.7.0/node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm             : @prisma/prisma-schema-wasm 5.7.0-41.79fb5193cf0a8fdbef536e4b4a159cad677ab1b9
Default Engines Hash    : 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9
Studio                  : 0.495.0
@silverbucket silverbucket added the kind/bug A reported bug. label Dec 16, 2023
@danx2y
Copy link

danx2y commented Dec 18, 2023

Although I haven't used with mongodb, I recommend to type below

//schema.prisma
datasource db {
  provider     = "mongodb"
  url          = env("DATABASE_URL")
  relationMode = "prisma"
}

@silverbucket
Copy link
Author

@daeb2a Thanks for the suggestion, I gave that a try but it didn't seem to change the behavior at all.

@kimberli
Copy link

I'm seeing this as well (with a postgresql provider) even though Prisma Studio was working for me a few days ago. I've tried running the suggested command (prisma platform auth login --early-access) and clearing site data. I'm also using this with Vercel, so the environment variables are loaded with vercel env pull .env.

prisma                  : 5.7.0                                                                                                                                                                            │
@prisma/client          : 5.7.0                                                                                                                                                                            │
Computed binaryTarget   : darwin-arm64                                                                                                                                                                     │
Operating System        : darwin                                                                                                                                                                           │
Architecture            : arm64                                                                                                                                                                            │
Node.js                 : v20.10.0                                                                                                                                                                         │
Query Engine (Node-API) : libquery-engine 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)                                               │
Schema Engine           : schema-engine-cli 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9 (at node_modules/@prisma/engines/schema-engine-darwin-arm64)                                                          │
Schema Wasm             : @prisma/prisma-schema-wasm 5.7.0-41.79fb5193cf0a8fdbef536e4b4a159cad677ab1b9                                                                                                     │
Default Engines Hash    : 79fb5193cf0a8fdbef536e4b4a159cad677ab1b9                                                                                                                                         │
Studio                  : 0.495.0

@miguelff miguelff added kind/regression A reported bug in functionality that used to work before. topic: studio tech/typescript Issue for tech TypeScript. team/client labels Dec 20, 2023
@aqrln
Copy link
Member

aqrln commented Dec 20, 2023

@silverbucket does Prisma Client work with the same connection string?

@kimberli the error in the original report comes from the MongoDB driver, I don't think you could be getting it with postgresql provider. Could you please share the error that you got?

@miguelff miguelff added the bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. label Dec 20, 2023
@kimberli
Copy link

Ah sorry, here's the error message I'm getting in the browser (when I try to commit changes in Prisma Studio)

Failed to commit changes: 
Invalid `f=e.match(J2t)?.[1]??"",g=e.match(Q2t)?.[1]??null,v=e.match(Z2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(`${c.prismaClient}/runtime/${u}`),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,GN.createHash)("sha256").update()` invocation in
/Users/kim/project/node_modules/prisma/build/index.js:1521:12640

  1518 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}else return on(`Accelerate enabled. Use your secure API key in your Accelerate connection string to authenticate requests.
  1519 
  1520 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}};var zR={};da(zR,{$:()=>GR,Create:()=>VR,Delete:()=>HR,Show:()=>WR});var GR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var VR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project,"--name":String,"-n":"--name"});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=Co(n,["--name","-n"]),c=await fr({token:i,path:`/${a}/${o}/settings/api-keys/create`,route:"_app.$organizationId_.$projectId.settings.api-keys.create",payload:{displayName:u}});if(c.error?.message)throw new Error(c.error.message);return on(`New API Key created: ${c.data.tenantAPIKey}`)}};var HR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project,"--apikey":String});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=Gt(n,["--apikey"]);if(ee(u))return u;let c=await fr({token:i,path:`/${a}/${o}/settings/api-keys`,route:"_app.$organizationId_.$projectId.settings.api-keys",payload:{id:u}});if(c.error?.message)throw new Error(c.error.message);return on(`API Key ${c.data.displayName} deleted.`)}};var WR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=await fr({token:i,path:`/${a}/${o}/settings/api-keys`,route:"_app.$organizationId_.$projectId.settings.api-keys"});return console.table(u.serviceKeys.map(({id:c,displayName:p,createdAt:l})=>({id:c,createdAt:l,name:p})),["id","name","createdAt"]),""}};var XR={};da(XR,{$:()=>KR,Login:()=>$5,Logout:()=>q5,Show:()=>YR});var KR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var g2e=L(h2e()),v2e=L(v0()),y2e=L(require("http"));var b2e=L(Q3()),M5=L(Bf());var x2e=ue("prisma:cli:platform:login"),$5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;if(r.token)return`Already authenticated. Run ${Y(Ee("prisma platform auth show --early-access"))} to see the current user.`;console.info("Authenticating to Prisma Platform CLI via browser");let n=y2e.default.createServer(),i=await(0,g2e.default)(n,0,"127.0.0.1"),a=await llt({connection:"github",redirectTo:i.href});console.info("Visit the following URL in your browser to authenticate:"),console.info(ye(a.href));try{let[o]=await Promise.all([new Promise((c,p)=>{n.once("request",(l,f)=>{n.close(),f.setHeader("connection","close");let g=new URL(l.url||"/","http://localhost").searchParams,v=g.get("token")??"",E=g.get("error"),x=new URL("/auth/cli",$R);if(E)x.pathname+="/error",x.searchParams.set("error",E),p(new Error(E));else{let S=flt(g.get("user")??"");if(S){g.delete("token"),g.delete("user"),x.pathname+="/success";let C=new URLSearchParams({...Object.fromEntries(g.entries()),email:S.email});x.search=C.toString(),c({token:v,user:S})}else x.pathname+="/error",x.searchParams.set("error","Invalid user"),p(new Error("Invalid user"))}f.statusCode=302,f.setHeader("location",x.href),f.end()}),n.once("error",p)}),(0,b2e.default)(a.href)]),u=await d2e({token:o.token});if(ee(u))throw u;return on(`Authentication successful for ${o.user.email}`)}catch(o){throw new Error(`Authentication failed: ${ee(o)?o.message:""}`)}}},llt=async e=>{let r=await v2e.getSignature().catch(o=>(x2e(`await checkpoint.getSignature() failed silently with ${o}`),null)),n={client:`${M5.name}@${M5.version}`,signature:r,...e},i=Buffer.from(JSON.stringify(n),"utf-8").toString("base64"),a=new URL("/auth/cli",$R);return a.searchParams.set("state",i),a},dlt=e=>{if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.id=="string"&&typeof r.displayName=="string"&&typeof r.handle=="string"&&typeof r.email=="string"},flt=e=>{try{let r=JSON.parse(Buffer.from(e,"base64").toString("utf-8"));return dlt(r)?r:null}catch(r){return x2e(`parseUser() failed silently with ${r}`),null}};var q5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;return r.token?(await f2e(),on("You have logged out")):`You are not currently logged in. Run ${Y(Ee("prisma platform auth login --early-access"))} to log in.`}};var YR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.global});if(ee(n))return n;let i=await Cr(n),a=await fr({token:i,path:"/settings/account",route:"_app._user.settings.account"});return console.info(`Currently authenticated as ${Y(a.user.email)}
→ 1521 `),Cc([["id",a.user.id],["handle",a.user.handle],["email",a.user.email],["displayName",a.user.displayName]])}};var tI={};da(tI,{$:()=>JR,Create:()=>QR,Delete:()=>ZR,Show:()=>eI});var JR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var QR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.workspace,"--name":String,"-n":"--name"});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Co(n,["--name","-n"]),u=await fr({token:i,path:`/${a}/overview/create`,route:"_app.$organizationId.overview.create",payload:{displayName:o}});if(u.error)throw new Error(`${u.error.name}: ${u.error.message}`);return on(`Project ${u.data.displayName} - ${u.data.id} created.`)}};var ZR=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.project});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=Gt(n,["--project","-p"]);if(ee(o))return o;let u=await fr({token:i,path:`/${a}/${o}/settings/general`,route:"_app.$organizationId_.$projectId.settings.general",payload:{intent:"delete"}});if(u.error)throw new Error(`${u.error.name}: ${u.error.message}`);return on(`Project ${u.data.displayName} - ${u.data.id} deleted.`)}};var eI=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.workspace});if(ee(n))return n;let i=await Cr(n),a=Gt(n,["--workspace","-w"]);if(ee(a))return a;let o=await fr({token:i,path:`/${a}/overview`,route:"_app.$organizationId.overview"});return console.table(o.organization.projects.map(({id:u,displayName:c,createdAt:p})=>({id:u,createdAt:p,name:c})),["id","name","createdAt"]),""}};var iI={};da(iI,{$:()=>rI,Show:()=>nI});var rI=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ca(this.commands,r)}};var nI=class e{static new(){return new e}async parse(r){let n=pe(r,{...Dr.global});if(ee(n))return n;let i=await Cr(n),a=await fr({token:i,path:"/settings/workspaces",route:"_app._user.settings.workspaces"});return console.table(a.organizations.map(o=>({id:o.id,name:o.displayName,createdAt:o.createdAt})),["id","name","createdAt"]),""}};var K8e=require("@prisma/engines");var w2e=require("buffer");function E2e(e,r,n,i){Object.defineProperty(e,r,{get:n,set:i,enumerable:!0,configurable:!0})}var _2e={};E2e(_2e,"serializeRPCMessage",()=>oI);E2e(_2e,"deserializeRPCMessage",()=>uI);var aI="PrismaBigInt::",sI="PrismaBytes::";function oI(e){return JSON.stringify(e,(r,n)=>typeof n=="bigint"?aI+n:n?.type==="Buffer"&&Array.isArray(n?.data)?sI+w2e.Buffer.from(n.data).toString("base64"):n)}function uI(e){return JSON.parse(e,(r,n)=>typeof n=="string"&&n.startsWith(aI)?BigInt(n.substr(aI.length)):typeof n=="string"&&n.startsWith(sI)?n.substr(sI.length):n)}var q8e=L(O2e()),O9=L(w8e()),j8e=L(require("http")),B8e=L(S8e()),U8e=require("zlib");var Ns=require("path");var GN=require("crypto"),O8e=L(qN());function A9(e,r,n,i){Object.defineProperty(e,r,{get:n,set:i,enumerable:!0,configurable:!0})}var R8e=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{},jN={},P9={},Ma=R8e.parcelRequire1308;Ma==null&&(Ma=function(e){if(e in jN)return jN[e].exports;if(e in P9){var r=P9[e];delete P9[e];var n={id:e,exports:{}};return jN[e]=n,r.call(n.exports,n,n.exports),n.exports}var i=new Error("Cannot find module '"+e+"'");throw i.code="MODULE_NOT_FOUND",i},Ma.register=function(r,n){P9[r]=n},R8e.parcelRequire1308=Ma);Ma.register("9lTzd",function(module,exports){A9(module.exports,"guessEnginePaths",()=>guessEnginePaths),A9(module.exports,"guessPrismaClientPath",()=>guessPrismaClientPath);var $5COlq=Ma("5COlq");async function guessEnginePaths({forceBinary,forceLibrary,resolveOverrides}){let queryEngineName,queryEngineType;if(forceLibrary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","library"),queryEngineType="library"):forceBinary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","binary"),queryEngineType="binary"):(queryEngineName=void 0,queryEngineType=void 0),!queryEngineName||!queryEngineType)return{queryEngine:void 0};let queryEnginePath;if(resolveOverrides[".prisma/client"])queryEnginePath=(0,Ns.resolve)(resolveOverrides[".prisma/client"],`../${queryEngineName}`);else if(resolveOverrides["@prisma/engines"])queryEnginePath=(0,Ns.resolve)(resolveOverrides["@prisma/engines"],`../../${queryEngineName}`);else{let atPrismaEnginesPath;try{atPrismaEnginesPath=eval("require.resolve('@prisma/engines')")}catch(e){throw new Er…

@aqrln
Copy link
Member

aqrln commented Dec 21, 2023

@kimberli it looks like the error message is stripped, it only contains the minified source code where the error happened which ends at some point with an ellipsis, and the actual, well, message is missing 😞 Did you get it in a popup in UI or in the browser's console? If it's the former, is there a full messsage in the console by any chance?

@aqrln
Copy link
Member

aqrln commented Dec 21, 2023

Opened prisma/prisma#22492

@kimberli
Copy link

kimberli commented Dec 21, 2023

It's in the popup UI, and I don't see a console error. The last message I see is Committing actions: ...
image

I think I figured it out - my schema had an incorrect uniqueness constraint, and that was being swallowed by the error UI.

@silverbucket
Copy link
Author

@silverbucket does Prisma Client work with the same connection string?

@aqrln I'm not sure what you mean by "the same connection string" ?

@aqrln
Copy link
Member

aqrln commented Dec 23, 2023

@kimberli we should definitely fix how the errors are being displayed in Studio, I agree that right now it is very hard to figure out what happened when something goes wrong. I opened an issue, hopefully we can prioritise it.

@silverbucket same database URL

@silverbucket
Copy link
Author

@silverbucket same database URL

Same database URL as what?

@silverbucket
Copy link
Author

ping @aqrln could you clarify specifically what you're asking me to try?

@aqrln
Copy link
Member

aqrln commented Jan 2, 2024

@silverbucket I wanted to clarify whether the Prisma Client in your application works (assuming you use it at all) with the same database and only Studio is affected, or both are affected.

@Jsox
Copy link

Jsox commented Jan 3, 2024

Hello, did you prisma db push?
I had the same error.

@janpio janpio transferred this issue from prisma/prisma Jan 5, 2024
@janpio
Copy link
Contributor

janpio commented Jan 5, 2024

@Jsox What do you mean with "same error"? Can you share the error? What database are you using?
You most probably did not have the same error as @silverbucket had, as that was a connection error to a MongoDB database when running a Prisma Client query. db push does not run any of these. But looking forward to more information.

@janpio janpio removed kind/regression A reported bug in functionality that used to work before. tech/typescript Issue for tech TypeScript. topic: studio labels Jan 5, 2024
@silverbucket
Copy link
Author

silverbucket commented Jan 5, 2024

I wanted to clarify whether the Prisma Client in your application works (assuming you use it at all) with the same database and only Studio is affected, or both are affected.

Thanks for the clarification @aqrln, regarding the Prisma Client, when I try to save a record to the DB it fails with:

Argument `translatesTo`: Invalid value provided. Expected WordCreateNestedManyWithoutTranslatesFromInput or WordUncheckedCreateNestedManyWithoutTranslatesFromInput, provided ().

However, based on the documentation, and the schema validation, everything seems to be written out correctly (It's the exact schema as written in this ticket).

$ cat prisma/schema.prisma 
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
  relationMode = "prisma"
}

enum Language {
  CZECH
  ENGLISH
}

model Word {
  id               String   @id @default(auto()) @map("_id") @db.ObjectId
  lang             Language
  name             String
  image            String
  translatesTo     Word[]   @relation("WordTranslations", fields: [translatesToId], references: [id])
  translatesToId   String[] @db.ObjectId
  translatesFrom   Word[]   @relation("WordTranslations", fields: [translatesFromId], references: [id])
  translatesFromId String[] @db.ObjectId
  definition       String
  sentence         String
}
$ pnpx prisma validate prisma/schema.prisma 
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
The schema at prisma/schema.prisma is valid 🚀

@mariangle
Copy link

i had the same error. using npx prisma db push again solved it. in my case i updated my .env and i assume db push reads ur recent .env

@gaurangkhera
Copy link

Facing the same issue here, nothing's really solving it.

@wflanagan
Copy link

wflanagan commented Jan 9, 2024

For me, it was that I was trying to access using the username postgres. When I changed the DATABASE_URL env to my local user name on my mac, I was able to access my database. I am using a DATABASE_URL in another app (that Prisma is connecting to its data) without a problem. So, my guess is that it's something related to Prisma Studio and non "accelerate" mode. If your DATABASE_URL has a username of postgres try changing that to something else that's valid for access to your postgres DB.

@desneck
Copy link

desneck commented Jan 18, 2024

I was having the same problem with a specific model, have no idea about the root cause but when i deleted every @map in the model's schema the error is gone.

@tmnrp
Copy link

tmnrp commented Jan 21, 2024

If it helps...

providing env file solved my issue
dotenv -e .env.local -- pnpx prisma studio

@nwazuo
Copy link

nwazuo commented Jan 22, 2024

I was able to solve by running prisma migrate. It seems that the prisma client being used by the studio was failing to execute db operations successfully because my schema wasn't in sync with the client (as expected, but not clear from the error message).

@sguillia
Copy link

Solution: downgrade to see the real error message.

With Prisma 5.8.1

Message: Error in Prisma Client request: 

Invalid `f=e.match(V2t)?.[1]??"",g=e.match(H2t)?.[1]??null,v=e.match(W2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(`${c.prismaClient}/runtime/${u}`),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,jN.createHash)("sha256").update()` invocation in ...

With Prisma 5.4

Message: Error in Prisma Client request: 

Invalid `prisma.user.findMany()` invocation:

error: Environment variable not found: POSTGRESQL_CONNECTION_URI.

The issue is about the error message not being displayed properly.

Once you see the actual error message, it's easy to fix (environment variable issue in my case).

@ayub48
Copy link

ayub48 commented Jan 27, 2024

Hello guys. I have the same problem with Prisma and mongodb and nothing helps;

this is my code:

const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
import { NextResponse } from "next/server";
export const GET = async () => {
  try {
    const articles = await prisma.article.findMany()
    return new NextResponse(JSON.stringify(articles))
  } catch (error) {
    console.log(error);
    return new NextResponse(
      JSON.stringify({ message: "SomeThing went wrong" })
    );
  }
};

and this is my schema:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}


model Category {
  id  String @id @default(cuid()) @map("_id")
  title  String
  slug   String @unique
  Articles Article[]
  }
  
  model Article {
    id     String @id @default(auto()) @map("_id") @db.ObjectId
    title  String
    text   String 
    slug   String @unique
    createdaAt DateTime @default(now())
    views Int @default(0)
    cat Category @relation(fields: [catSlug], references: [slug])
    catSlug String
    comments Comment[]
  }
  
  model Comment {
    id     String @id @default(auto()) @map("_id") @db.ObjectId
    title  String
    text   String
    writer String
    views Int @default(0)
    createdaAt DateTime @default(now())
    article Article @relation(fields: [articleSlug], references: [slug])
    articleSlug String
  }

and the .env file:

DATABASE_URL="mongodb://localhost:27017/articlesdb"

and this is the error message when I press the save button in Prisma Studio:

Failed to commit changes:
Invalid f=e.match(V2t)?.[1]??"",g=e.match(H2t)?.[1]??null,v=e.match(W2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(${c.prismaClient}/runtime/${u}),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,jN.createHash)("sha256").update() invocation in
/Users/ayub/Desktop/articles/node_modules/prisma/build/index.js:1521:12459

1518 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}else return ai(Accelerate enabled. Use your secure API key in your Accelerate connection string to authenticate requests. 1519 1520 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")})}};var GR={};pa(GR,{$:()=>qR,Create:()=>jR,Delete:()=>BR,Show:()=>UR});var qR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return oa(this.commands,r)}};var jR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project,"--name":String,"-n":"--name"});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=_o(i,["--name","-n"]),c=await fr({token:n,path:/${a}/${o}/settings/api-keys/create,route:"app.$organizationId.$projectId.settings.api-keys.create",payload:{displayName:u}});if(c.error?.message)throw new Error(c.error.message);return ai(New API Key created: ${c.data.tenantAPIKey})}};var BR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project,"--apikey":String});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=Gt(i,["--apikey"]);if(ee(u))return u;let c=await fr({token:n,path:/${a}/${o}/settings/api-keys,route:"app.$organizationId.$projectId.settings.api-keys",payload:{id:u}});if(c.error?.message)throw new Error(c.error.message);return ai(API Key ${c.data.displayName} deleted.)}};var UR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=await fr({token:n,path:/${a}/${o}/settings/api-keys,route:"app.$organizationId.$projectId.settings.api-keys"});return console.table(u.serviceKeys.map(({id:c,displayName:p,createdAt:l})=>({id:c,createdAt:l,name:p})),["id","name","createdAt"]),""}};var WR={};pa(WR,{$:()=>VR,Login:()=>F5,Logout:()=>$5,Show:()=>HR});var VR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return oa(this.commands,r)}};var m2e=L(f2e()),h2e=L(sf()),g2e=L(require("http"));var v2e=L(X3()),L5=L(jf());var y2e=ue("prisma:cli:platform:login"),F5=class e{static new(){return new e}async parse(){let r=await w2();if(ee(r))throw r;if(r.token)returnAlready authenticated. Run ${Y(Ee("prisma platform auth show --early-access"))} to see the current user.;console.info("Authenticating to Prisma Platform CLI via browser");let i=g2e.default.createServer(),n=await(0,m2e.default)(i,0,"127.0.0.1"),a=await nlt({connection:"github",redirectTo:n.href});console.info("Visit the following URL in your browser to authenticate:"),console.info(ye(a.href));try{let[o]=await Promise.all([new Promise((c,p)=>{i.once("request",(l,f)=>{i.close(),f.setHeader("connection","close");let g=new URL(l.url||"/","http://localhost").searchParams,v=g.get("token")??"",E=g.get("error"),x=new URL("/auth/cli",NR);if(E)x.pathname+="/error",x.searchParams.set("error",E),p(new Error(E));else{let S=slt(g.get("user")??"");if(S){g.delete("token"),g.delete("user"),x.pathname+="/success";let C=new URLSearchParams({...Object.fromEntries(g.entries()),email:S.email});x.search=C.toString(),c({token:v,user:S})}else x.pathname+="/error",x.searchParams.set("error","Invalid user"),p(new Error("Invalid user"))}f.statusCode=302,f.setHeader("location",x.href),f.end()}),i.once("error",p)}),(0,v2e.default)(a.href)]),u=await p2e({token:o.token});if(ee(u))throw u;return ai(Authentication successful for ${o.user.email})}catch(o){throw new Error(Authentication failed: ${ee(o)?o.message:""})}}},nlt=async e=>{let r=await h2e.getSignature().catch(o=>(y2e(await checkpoint.getSignature() failed silently with ${o}),null)),i={client:${L5.name}@${L5.version},signature:r,...e},n=Buffer.from(JSON.stringify(i),"utf-8").toString("base64"),a=new URL("/auth/cli",NR);return a.searchParams.set("state",n),a},alt=e=>{if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.id=="string"&&typeof r.displayName=="string"&&typeof r.handle=="string"&&typeof r.email=="string"},slt=e=>{try{let r=JSON.parse(Buffer.from(e,"base64").toString("utf-8"));return alt(r)?r:null}catch(r){return y2e(parseUser() failed silently with ${r}),null}};var $5=class e{static new(){return new e}async parse(){let r=await w2();if(ee(r))throw r;return r.token?(await l2e(),ai("You have logged out")):You are not currently logged in. Run ${Y(Ee("prisma platform auth login --early-access"))} to log in.}};var HR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.global});if(ee(i))return i;let n=await Dr(i),a=await fr({token:n,path:"/settings/account",route:"_app._user.settings.account"});return console.info(Currently authenticated as ${Y(a.user.email)} → 1521 ),Sc([["id",a.user.id],["handle",a.user.handle],["email",a.user.email],["displayName",a.user.displayName]])}};var JR={};pa(JR,{$:()=>zR,Create:()=>KR,Delete:()=>YR,Show:()=>XR});var zR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return oa(this.commands,r)}};var KR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.workspace,"--name":String,"-n":"--name"});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=_o(i,["--name","-n"]),u=await fr({token:n,path:/${a}/overview/create,route:"_app.$organizationId.overview.create",payload:{displayName:o}});if(u.error)throw new Error(${u.error.name}: ${u.error.message});return ai(Project ${u.data.displayName} - ${u.data.id} created.)}};var YR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=await fr({token:n,path:/${a}/${o}/settings/general,route:"app.$organizationId.$projectId.settings.general",payload:{intent:"delete"}});if(u.error)throw new Error(${u.error.name}: ${u.error.message});return ai(Project ${u.data.displayName} - ${u.data.id} deleted.)}};var XR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.workspace});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=await fr({token:n,path:/${a}/overview,route:"_app.$organizationId.overview"});return console.table(o.organization.projects.map(({id:u,displayName:c,createdAt:p})=>({id:u,createdAt:p,name:c})),["id","name","createdAt"]),""}};var eI={};pa(eI,{$:()=>QR,Show:()=>ZR});var QR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return oa(this.commands,r)}};var ZR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.global});if(ee(i))return i;let n=await Dr(i),a=await fr({token:n,path:"/settings/workspaces",route:"_app._user.settings.workspaces"});return console.table(a.organizations.map(o=>({id:o.id,name:o.displayName,createdAt:o.createdAt})),["id","name","createdAt"]),""}};var B8e=require("@prisma/engines");var b2e=require("buffer");function x2e(e,r,i,n){Object.defineProperty(e,r,{get:i,set:n,enumerable:!0,configurable:!0})}var w2e={};x2e(w2e,"serializeRPCMessage",()=>iI);x2e(w2e,"deserializeRPCMessage",()=>nI);var tI="PrismaBigInt::",rI="PrismaBytes::";function iI(e){return JSON.stringify(e,(r,i)=>typeof i=="bigint"?tI+i:i?.type==="Buffer"&&Array.isArray(i?.data)?rI+b2e.Buffer.from(i.data).toString("base64"):i)}function nI(e){return JSON.parse(e,(r,i)=>typeof i=="string"&&i.startsWith(tI)?BigInt(i.substr(tI.length)):typeof i=="string"&&i.startsWith(rI)?i.substr(rI.length):i)}var I8e=L(P2e()),T9=L(b8e()),N8e=L(require("http")),k8e=L(E8e()),F8e=require("zlib");var Os=require("path");var jN=require("crypto"),P8e=L(FN());function MN(e,r,i,n){Object.defineProperty(e,r,{get:i,set:n,enumerable:!0,configurable:!0})}var A8e=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{},LN={},C9={},rc=A8e.parcelRequire1308;rc==null&&(rc=function(e){if(e in LN)return LN[e].exports;if(e in C9){var r=C9[e];delete C9[e];var i={id:e,exports:{}};return LN[e]=i,r.call(i.exports,i,i.exports),i.exports}var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n},rc.register=function(r,i){C9[r]=i},A8e.parcelRequire1308=rc);rc.register("9lTzd",function(module,exports){MN(module.exports,"guessEnginePaths",()=>guessEnginePaths),MN(module.exports,"guessPrismaClientPath",()=>guessPrismaClientPath);var $5COlq=rc("5COlq");async function guessEnginePaths({forceBinary,forceLibrary,resolveOverrides}){let queryEngineName,queryEngineType;if(forceLibrary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","library"),queryEngineType="library"):forceBinary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","binary"),queryEngineType="binary"):(queryEngineName=void 0,queryEngineType=void 0),!queryEngineName||!queryEngineType)return{queryEngine:void 0};let queryEnginePath;if(resolveOverrides[".prisma/client"])queryEnginePath=(0,Os.resolve)(resolveOverrides[".prisma/client"],../${queryEngineName});else if(resolveOverrides["@prisma/engines"])queryEnginePath=(0,Os.resolve)(resolveOverrides["@prisma/engines"],../../${queryEngineName});else{let atPrismaEnginesPath;try{atPrismaEnginesPath=eval("require.resolve('@prisma/engines')")}catch(e){throw new Error("Unable to resolve Prisma engine paths. This is a bug.")}queryEnginePath=(0,Os.resolve)(atPrismaEnginesPath../../${queryEngineName})}return{queryEngine:{type:queryEngineType,path:queryEnginePath}}}function guessPrismaClientPath({resolveOverrides}){let prismaClientPath=resolveOverrides["@prisma/client"]||eval("require.resolve('@prisma/client')");return(0,Os.resolve)(prismaClientPath,"../")}});rc.register("5COlq",function(e,r){MN(e.exports,"prismaEngineName",()=>i);async function i(n,a){let o=await Ar(),u=o==="windows"?".exe":"";if(a==="library")return La(o,"fs");if(a==="binary")return${n}-${o}${u};throw new Error(Unknown engine type: ${a})}});function G2t(e){return{models:$N(e.models),enums:$N(e.enums),types:$N(e.types)}}function $N(e){let r={};for(let{name:i,...n}of e)r[i]=n;return r}var K2=(0,P8e.debug)("prisma:studio-pcw"),V2t=/^\sdatasource\s+([^\s]+)\s{/m,H2t=/url *= env("(.)")/,W2t=/url *= "(.)"/;async function z2t({schema:e,schemaPath:r,dmmf:i,datasourceProvider:n,previewFeatures:a,datasources:o,engineType:u,paths:c,directUrl:p,versions:l}){let f=e.match(V2t)?.[1]??"",g=e.match(H2t)?.[1]??null,v=e.match(W2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(${c.prismaClient}/runtime/${u}),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,jN.createHash)("sha256").update(
Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set. https://pris.ly/d/mongodb-replica-set

connection to my db is done because my models are created in the database.

Screenshot 2024-01-27 at 08 00 14

@janpio
Copy link
Contributor

janpio commented Jan 27, 2024

This is the relevant bit of the error message @ayub48:

Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set. pris.ly/d/mongodb-replica-set

If you can not figure this out, please open a discussion over at https://github.com/prisma/prisma/discussions/

@EthanQuarry
Copy link

Hello, did you prisma db push? I had the same error.

This is the solution some of us forgot to re-initialize the database with out changes in the schema, thanks!

@joelrb
Copy link

joelrb commented Feb 20, 2024

I just got the same error. Using Prisma 5.9.1 and PostgreSQL 16. I found the reason for this, at least in my project. Prisma Studio error occurred when there's data in the database.

Editing data in pgAdmin didn't work. Wouldn't allow me to save update on UserType in User table.

Two quirky solutions:

  1. Undo the change on enum UserType
  2. Delete the users with the "Provider" UserType, which resolved the Prisma Studio error in the browser.

HERE'S THE CAUSE OF MY PRISMA STUDIO ERROR:

I changed my enum,

from:
enum UserType {
Provider
Client
@@Schema("sc_users")
}

To:
enum UserType {
Admin
Client
@@Schema("sc_users")
}

then do 'npx prisma generate' (Prisma Studio error in brower)
and 'npx prisma db push' gives an error:

DB PUSH ERROR************
Error: ERROR: invalid input value for enum sc_users."UserType_new": "Provider"
0: sql_schema_connector::apply_migration::migration_step
with step=AlterEnum(AlterEnum { id: MigrationPair { previous: EnumId(4), next: EnumId(2) }, created_variants: ["Admin"], dropped_variants: ["Provider"], previous_usages_as_default: [(TableColumnId(95), Some(TableColumnId(11)))] })
at schema-engine\connectors\sql-schema-connector\src\apply_migration.rs:21
1: sql_schema_connector::apply_migration::apply_migration
at schema-engine\connectors\sql-schema-connector\src\apply_migration.rs:10
2: schema_core::state::SchemaPush
at schema-engine\core\src\state.rs:433

PRISMA STUDIO ERROR************
Message: Error in Prisma Client request:

Invalid f=e.match(V2t)?.[1]??"",g=e.match(H2t)?.[1]??null,v=e.match(W2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(${c.prismaClient}/runtime/${u}),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,jN.createHash)("sha256").update() invocation in
D:\Projects\Seira\Web\seiraclient\node_modules\prisma\build\index.js:1555:12459

1552 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}else return ai(Accelerate enabled. Use your secure API key in your Accelerate connection string to authenticate requests. 1553 1554 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")})}};var VR={};la(VR,{$:()=>BR,Create:()=>jR,Delete:()=>UR,Show:()=>GR});var BR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var jR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project,"--name":String,"-n":"--name"});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=So(i,["--name","-n"]),c=await fr({token:n,path:/${a}/${o}/settings/api-keys/create,route:"app.$organizationId.$projectId.settings.api-keys.create",payload:{displayName:u}});if(c.error?.message)throw new Error(c.error.message);return ai(New API Key created: ${c.data.tenantAPIKey})}};var UR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project,"--apikey":String});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=Gt(i,["--apikey"]);if(ee(u))return u;let c=await fr({token:n,path:/${a}/${o}/settings/api-keys,route:"app.$organizationId.$projectId.settings.api-keys",payload:{id:u}});if(c.error?.message)throw new Error(c.error.message);return ai(API Key ${c.data.displayName} deleted.)}};var GR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=await fr({token:n,path:/${a}/${o}/settings/api-keys,route:"app.$organizationId.$projectId.settings.api-keys"});return console.table(u.serviceKeys.map(({id:c,displayName:p,createdAt:l})=>({id:c,createdAt:l,name:p})),["id","name","createdAt"]),""}};var zR={};la(zR,{$:()=>HR,Login:()=>F5,Logout:()=>$5,Show:()=>WR});var HR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var m2e=L(f2e()),h2e=L(of()),g2e=L(require("http"));var v2e=L(X3()),L5=L(jf());var y2e=ue("prisma:cli:platform:login"),F5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;if(r.token)returnAlready authenticated. Run ${Y(Ee("prisma platform auth show --early-access"))} to see the current user.;console.info("Authenticating to Prisma Platform CLI via browser");let i=g2e.default.createServer(),n=await(0,m2e.default)(i,0,"127.0.0.1"),a=await nlt({connection:"github",redirectTo:n.href});console.info("Visit the following URL in your browser to authenticate:"),console.info(ye(a.href));try{let[o]=await Promise.all([new Promise((c,p)=>{i.once("request",(l,f)=>{i.close(),f.setHeader("connection","close");let g=new URL(l.url||"/","http://localhost").searchParams,v=g.get("token")??"",E=g.get("error"),x=new URL("/auth/cli",kR);if(E)x.pathname+="/error",x.searchParams.set("error",E),p(new Error(E));else{let S=slt(g.get("user")??"");if(S){g.delete("token"),g.delete("user"),x.pathname+="/success";let C=new URLSearchParams({...Object.fromEntries(g.entries()),email:S.email});x.search=C.toString(),c({token:v,user:S})}else x.pathname+="/error",x.searchParams.set("error","Invalid user"),p(new Error("Invalid user"))}f.statusCode=302,f.setHeader("location",x.href),f.end()}),i.once("error",p)}),(0,v2e.default)(a.href)]),u=await p2e({token:o.token});if(ee(u))throw u;return ai(Authentication successful for ${o.user.email})}catch(o){throw new Error(Authentication failed: ${ee(o)?o.message:""})}}},nlt=async e=>{let r=await h2e.getSignature().catch(o=>(y2e(await checkpoint.getSignature() failed silently with ${o}),null)),i={client:${L5.name}@${L5.version},signature:r,...e},n=Buffer.from(JSON.stringify(i),"utf-8").toString("base64"),a=new URL("/auth/cli",kR);return a.searchParams.set("state",n),a},alt=e=>{if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.id=="string"&&typeof r.displayName=="string"&&typeof r.handle=="string"&&typeof r.email=="string"},slt=e=>{try{let r=JSON.parse(Buffer.from(e,"base64").toString("utf-8"));return alt(r)?r:null}catch(r){return y2e(parseUser() failed silently with ${r}),null}};var $5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;return r.token?(await l2e(),ai("You have logged out")):You are not currently logged in. Run ${Y(Ee("prisma platform auth login --early-access"))} to log in.}};var WR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.global});if(ee(i))return i;let n=await Dr(i),a=await fr({token:n,path:"/settings/account",route:"_app._user.settings.account"});return console.info(Currently authenticated as ${Y(a.user.email)} → 1555 ),Sc([["id",a.user.id],["handle",a.user.handle],["email",a.user.email],["displayName",a.user.displayName]])}};var QR={};la(QR,{$:()=>KR,Create:()=>YR,Delete:()=>XR,Show:()=>JR});var KR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var YR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.workspace,"--name":String,"-n":"--name"});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=So(i,["--name","-n"]),u=await fr({token:n,path:/${a}/overview/create,route:"_app.$organizationId.overview.create",payload:{displayName:o}});if(u.error)throw new Error(${u.error.name}: ${u.error.message});return ai(Project ${u.data.displayName} - ${u.data.id} created.)}};var XR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=await fr({token:n,path:/${a}/${o}/settings/general,route:"app.$organizationId.$projectId.settings.general",payload:{intent:"delete"}});if(u.error)throw new Error(${u.error.name}: ${u.error.message});return ai(Project ${u.data.displayName} - ${u.data.id} deleted.)}};var JR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.workspace});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=await fr({token:n,path:/${a}/overview,route:"_app.$organizationId.overview"});return console.table(o.organization.projects.map(({id:u,displayName:c,createdAt:p})=>({id:u,createdAt:p,name:c})),["id","name","createdAt"]),""}};var tI={};la(tI,{$:()=>ZR,Show:()=>eI});var ZR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var eI=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.global});if(ee(i))return i;let n=await Dr(i),a=await fr({token:n,path:"/settings/workspaces",route:"_app._user.settings.workspaces"});return console.table(a.organizations.map(o=>({id:o.id,name:o.displayName,createdAt:o.createdAt})),["id","name","createdAt"]),""}};var j8e=require("@prisma/engines");var b2e=require("buffer");function x2e(e,r,i,n){Object.defineProperty(e,r,{get:i,set:n,enumerable:!0,configurable:!0})}var w2e={};x2e(w2e,"serializeRPCMessage",()=>nI);x2e(w2e,"deserializeRPCMessage",()=>aI);var rI="PrismaBigInt::",iI="PrismaBytes::";function nI(e){return JSON.stringify(e,(r,i)=>typeof i=="bigint"?rI+i:i?.type==="Buffer"&&Array.isArray(i?.data)?iI+b2e.Buffer.from(i.data).toString("base64"):i)}function aI(e){return JSON.parse(e,(r,i)=>typeof i=="string"&&i.startsWith(rI)?BigInt(i.substr(rI.length)):typeof i=="string"&&i.startsWith(iI)?i.substr(iI.length):i)}var I8e=L(P2e()),T9=L(b8e()),N8e=L(require("http")),k8e=L(E8e()),F8e=require("zlib");var Is=require("path");var jN=require("crypto"),P8e=L(LN());function qN(e,r,i,n){Object.defineProperty(e,r,{get:i,set:n,enumerable:!0,configurable:!0})}var A8e=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{},$N={},C9={},rc=A8e.parcelRequire1308;rc==null&&(rc=function(e){if(e in $N)return $N[e].exports;if(e in C9){var r=C9[e];delete C9[e];var i={id:e,exports:{}};return $N[e]=i,r.call(i.exports,i,i.exports),i.exports}var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n},rc.register=function(r,i){C9[r]=i},A8e.parcelRequire1308=rc);rc.register("9lTzd",function(module,exports){qN(module.exports,"guessEnginePaths",()=>guessEnginePaths),qN(module.exports,"guessPrismaClientPath",()=>guessPrismaClientPath);var $5COlq=rc("5COlq");async function guessEnginePaths({forceBinary,forceLibrary,resolveOverrides}){let queryEngineName,queryEngineType;if(forceLibrary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","library"),queryEngineType="library"):forceBinary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","binary"),queryEngineType="binary"):(queryEngineName=void 0,queryEngineType=void 0),!queryEngineName||!queryEngineType)return{queryEngine:void 0};let queryEnginePath;if(resolveOverrides[".prisma/client"])queryEnginePath=(0,Is.resolve)(resolveOverrides[".prisma/client"],../${queryEngineName});else if(resolveOverrides["@prisma/engines"])queryEnginePath=(0,Is.resolve)(resolveOverrides["@prisma/engines"],../../${queryEngineName});else{let atPrismaEnginesPath;try{atPrismaEnginesPath=eval("require.resolve('@prisma/engines')")}catch(e){throw new Error("Unable to resolve Prisma engine paths. This is a bug.")}queryEnginePath=(0,Is.resolve)(atPrismaEnginesPath../../${queryEngineName})}return{queryEngine:{type:queryEngineType,path:queryEnginePath}}}function guessPrismaClientPath({resolveOverrides}){let prismaClientPath=resolveOverrides["@prisma/client"]||eval("require.resolve('@prisma/client')");return(0,Is.resolve)(prismaClientPath,"../")}});rc.register("5COlq",function(e,r){qN(e.exports,"prismaEngineName",()=>i);async function i(n,a){let o=await Ar(),u=o==="windows"?".exe":"";if(a==="library")return Ma(o,"fs");if(a==="binary")return${n}-${o}${u};throw new Error(Unknown engine type: ${a})}});function G2t(e){return{models:MN(e.models),enums:MN(e.enums),types:MN(e.types)}}function MN(e){let r={};for(let{name:i,...n}of e)r[i]=n;return r}var Y2=(0,P8e.debug)("prisma:studio-pcw"),V2t=/^\sdatasource\s+([^\s]+)\s{/m,H2t=/url *= env("(.)")/,W2t=/url *= "(.)"/;async function z2t({schema:e,schemaPath:r,dmmf:i,datasourceProvider:n,previewFeatures:a,datasources:o,engineType:u,paths:c,directUrl:p,versions:l}){let f=e.match(V2t)?.[1]??"",g=e.match(H2t)?.[1]??null,v=e.match(W2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(${c.prismaClient}/runtime/${u}),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,jN.createHash)("sha256").update(
Value 'Provider' not found in enum 'UserType'

Query:
{
"modelName": "User",
"operation": "findMany",
"args": {
"take": 100,
"skip": 0,
"select": {
"id": true,
"companyId": true,
"firstname": true,
"lastname": true,
"email": true,
"emailVerified": true,
"image": true,
"password": true,
"role": true,
"gender": true,
"isTwoFactorEnabled": true,
"twoFactorConfirmation": true,
"userType": true,
"createdDate": true,
"user": true
}
}
}

@joelrb
Copy link

joelrb commented Feb 20, 2024

Hello, did you prisma db push? I had the same error.

This is the solution some of us forgot to re-initialize the database with out changes in the schema, thanks!

Didn't work for me. See error in my reply.

@riyan707
Copy link

Solution (that worked for me):

Summary: Ensure password on pgAdmin4 is same password for your database environment

Environment & setup

OS: Windows 11
Database: PostgreSQL 16
Node.js version: v20.9.0

Prisma Version

Environment variables loaded from .env
prisma                  : 5.9.1
@prisma/client          : 5.9.1
Computed binaryTarget   : windows
Operating System        : win32
Architecture            : x64
Node.js                 : v20.9.0
Query Engine (Node-API) : libquery-engine 23fdc5965b1e05fc54e5f26ed3de66776b93de64 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine           : schema-engine-cli 23fdc5965b1e05fc54e5f26ed3de66776b93de64 (at node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm             : @prisma/prisma-schema-wasm 5.9.0-32.23fdc5965b1e05fc54e5f26ed3de66776b93de64
Default Engines Hash    : 23fdc5965b1e05fc54e5f26ed3de66776b93de64
Studio                  : 0.497.0

Error I received

Message: Error in Prisma Client request: 


Invalid `f=e.match(V2t)?.[1]??"",g=e.match(H2t)?.[1]??null,v=e.match(W2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(`${c.prismaClient}/runtime/${u}`),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,jN.createHash)("sha256").update()` invocation in
C:\Users\riyan\Documents\Personal\coding\live-fullstack\backend\node_modules\prisma\build\index.js:1555:12459

  1552 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}else return ai(`Accelerate enabled. Use your secure API key in your Accelerate connection string to authenticate requests.
  1553 
  1554 For more information, check out the Getting started guide here: ${ye("https://pris.ly/d/accelerate-getting-started")}`)}};var VR={};la(VR,{$:()=>BR,Create:()=>jR,Delete:()=>UR,Show:()=>GR});var BR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var jR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project,"--name":String,"-n":"--name"});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=So(i,["--name","-n"]),c=await fr({token:n,path:`/${a}/${o}/settings/api-keys/create`,route:"_app.$organizationId_.$projectId.settings.api-keys.create",payload:{displayName:u}});if(c.error?.message)throw new Error(c.error.message);return ai(`New API Key created: ${c.data.tenantAPIKey}`)}};var UR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project,"--apikey":String});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=Gt(i,["--apikey"]);if(ee(u))return u;let c=await fr({token:n,path:`/${a}/${o}/settings/api-keys`,route:"_app.$organizationId_.$projectId.settings.api-keys",payload:{id:u}});if(c.error?.message)throw new Error(c.error.message);return ai(`API Key ${c.data.displayName} deleted.`)}};var GR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=await fr({token:n,path:`/${a}/${o}/settings/api-keys`,route:"_app.$organizationId_.$projectId.settings.api-keys"});return console.table(u.serviceKeys.map(({id:c,displayName:p,createdAt:l})=>({id:c,createdAt:l,name:p})),["id","name","createdAt"]),""}};var zR={};la(zR,{$:()=>HR,Login:()=>F5,Logout:()=>$5,Show:()=>WR});var HR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var m2e=L(f2e()),h2e=L(of()),g2e=L(require("http"));var v2e=L(X3()),L5=L(jf());var y2e=ue("prisma:cli:platform:login"),F5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;if(r.token)return`Already authenticated. Run ${Y(Ee("prisma platform auth show --early-access"))} to see the current user.`;console.info("Authenticating to Prisma Platform CLI via browser");let i=g2e.default.createServer(),n=await(0,m2e.default)(i,0,"127.0.0.1"),a=await nlt({connection:"github",redirectTo:n.href});console.info("Visit the following URL in your browser to authenticate:"),console.info(ye(a.href));try{let[o]=await Promise.all([new Promise((c,p)=>{i.once("request",(l,f)=>{i.close(),f.setHeader("connection","close");let g=new URL(l.url||"/","http://localhost").searchParams,v=g.get("token")??"",E=g.get("error"),x=new URL("/auth/cli",kR);if(E)x.pathname+="/error",x.searchParams.set("error",E),p(new Error(E));else{let S=slt(g.get("user")??"");if(S){g.delete("token"),g.delete("user"),x.pathname+="/success";let C=new URLSearchParams({...Object.fromEntries(g.entries()),email:S.email});x.search=C.toString(),c({token:v,user:S})}else x.pathname+="/error",x.searchParams.set("error","Invalid user"),p(new Error("Invalid user"))}f.statusCode=302,f.setHeader("location",x.href),f.end()}),i.once("error",p)}),(0,v2e.default)(a.href)]),u=await p2e({token:o.token});if(ee(u))throw u;return ai(`Authentication successful for ${o.user.email}`)}catch(o){throw new Error(`Authentication failed: ${ee(o)?o.message:""}`)}}},nlt=async e=>{let r=await h2e.getSignature().catch(o=>(y2e(`await checkpoint.getSignature() failed silently with ${o}`),null)),i={client:`${L5.name}@${L5.version}`,signature:r,...e},n=Buffer.from(JSON.stringify(i),"utf-8").toString("base64"),a=new URL("/auth/cli",kR);return a.searchParams.set("state",n),a},alt=e=>{if(typeof e!="object"||e===null)return!1;let r=e;return typeof r.id=="string"&&typeof r.displayName=="string"&&typeof r.handle=="string"&&typeof r.email=="string"},slt=e=>{try{let r=JSON.parse(Buffer.from(e,"base64").toString("utf-8"));return alt(r)?r:null}catch(r){return y2e(`parseUser() failed silently with ${r}`),null}};var $5=class e{static new(){return new e}async parse(){let r=await E2();if(ee(r))throw r;return r.token?(await l2e(),ai("You have logged out")):`You are not currently logged in. Run ${Y(Ee("prisma platform auth login --early-access"))} to log in.`}};var WR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.global});if(ee(i))return i;let n=await Dr(i),a=await fr({token:n,path:"/settings/account",route:"_app._user.settings.account"});return console.info(`Currently authenticated as ${Y(a.user.email)}
→ 1555 `),Sc([["id",a.user.id],["handle",a.user.handle],["email",a.user.email],["displayName",a.user.displayName]])}};var QR={};la(QR,{$:()=>KR,Create:()=>YR,Delete:()=>XR,Show:()=>JR});var KR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var YR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.workspace,"--name":String,"-n":"--name"});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=So(i,["--name","-n"]),u=await fr({token:n,path:`/${a}/overview/create`,route:"_app.$organizationId.overview.create",payload:{displayName:o}});if(u.error)throw new Error(`${u.error.name}: ${u.error.message}`);return ai(`Project ${u.data.displayName} - ${u.data.id} created.`)}};var XR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.project});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=Gt(i,["--project","-p"]);if(ee(o))return o;let u=await fr({token:n,path:`/${a}/${o}/settings/general`,route:"_app.$organizationId_.$projectId.settings.general",payload:{intent:"delete"}});if(u.error)throw new Error(`${u.error.name}: ${u.error.message}`);return ai(`Project ${u.data.displayName} - ${u.data.id} deleted.`)}};var JR=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.workspace});if(ee(i))return i;let n=await Dr(i),a=Gt(i,["--workspace","-w"]);if(ee(a))return a;let o=await fr({token:n,path:`/${a}/overview`,route:"_app.$organizationId.overview"});return console.table(o.organization.projects.map(({id:u,displayName:c,createdAt:p})=>({id:u,createdAt:p,name:c})),["id","name","createdAt"]),""}};var tI={};la(tI,{$:()=>ZR,Show:()=>eI});var ZR=class e{constructor(r){this.commands=r}static new(r){return new e(r)}async parse(r){return ua(this.commands,r)}};var eI=class e{static new(){return new e}async parse(r){let i=pe(r,{...Sr.global});if(ee(i))return i;let n=await Dr(i),a=await fr({token:n,path:"/settings/workspaces",route:"_app._user.settings.workspaces"});return console.table(a.organizations.map(o=>({id:o.id,name:o.displayName,createdAt:o.createdAt})),["id","name","createdAt"]),""}};var j8e=require("@prisma/engines");var b2e=require("buffer");function x2e(e,r,i,n){Object.defineProperty(e,r,{get:i,set:n,enumerable:!0,configurable:!0})}var w2e={};x2e(w2e,"serializeRPCMessage",()=>nI);x2e(w2e,"deserializeRPCMessage",()=>aI);var rI="PrismaBigInt::",iI="PrismaBytes::";function nI(e){return JSON.stringify(e,(r,i)=>typeof i=="bigint"?rI+i:i?.type==="Buffer"&&Array.isArray(i?.data)?iI+b2e.Buffer.from(i.data).toString("base64"):i)}function aI(e){return JSON.parse(e,(r,i)=>typeof i=="string"&&i.startsWith(rI)?BigInt(i.substr(rI.length)):typeof i=="string"&&i.startsWith(iI)?i.substr(iI.length):i)}var I8e=L(P2e()),T9=L(b8e()),N8e=L(require("http")),k8e=L(E8e()),F8e=require("zlib");var Is=require("path");var jN=require("crypto"),P8e=L(LN());function qN(e,r,i,n){Object.defineProperty(e,r,{get:i,set:n,enumerable:!0,configurable:!0})}var A8e=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{},$N={},C9={},rc=A8e.parcelRequire1308;rc==null&&(rc=function(e){if(e in $N)return $N[e].exports;if(e in C9){var r=C9[e];delete C9[e];var i={id:e,exports:{}};return $N[e]=i,r.call(i.exports,i,i.exports),i.exports}var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n},rc.register=function(r,i){C9[r]=i},A8e.parcelRequire1308=rc);rc.register("9lTzd",function(module,exports){qN(module.exports,"guessEnginePaths",()=>guessEnginePaths),qN(module.exports,"guessPrismaClientPath",()=>guessPrismaClientPath);var $5COlq=rc("5COlq");async function guessEnginePaths({forceBinary,forceLibrary,resolveOverrides}){let queryEngineName,queryEngineType;if(forceLibrary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","library"),queryEngineType="library"):forceBinary?(queryEngineName=await $5COlq.prismaEngineName("query-engine","binary"),queryEngineType="binary"):(queryEngineName=void 0,queryEngineType=void 0),!queryEngineName||!queryEngineType)return{queryEngine:void 0};let queryEnginePath;if(resolveOverrides[".prisma/client"])queryEnginePath=(0,Is.resolve)(resolveOverrides[".prisma/client"],`../${queryEngineName}`);else if(resolveOverrides["@prisma/engines"])queryEnginePath=(0,Is.resolve)(resolveOverrides["@prisma/engines"],`../../${queryEngineName}`);else{let atPrismaEnginesPath;try{atPrismaEnginesPath=eval("require.resolve('@prisma/engines')")}catch(e){throw new Error("Unable to resolve Prisma engine paths. This is a bug.")}queryEnginePath=(0,Is.resolve)(atPrismaEnginesPath`../../${queryEngineName}`)}return{queryEngine:{type:queryEngineType,path:queryEnginePath}}}function guessPrismaClientPath({resolveOverrides}){let prismaClientPath=resolveOverrides["@prisma/client"]||eval("require.resolve('@prisma/client')");return(0,Is.resolve)(prismaClientPath,"../")}});rc.register("5COlq",function(e,r){qN(e.exports,"prismaEngineName",()=>i);async function i(n,a){let o=await Ar(),u=o==="windows"?".exe":"";if(a==="library")return Ma(o,"fs");if(a==="binary")return`${n}-${o}${u}`;throw new Error(`Unknown engine type: ${a}`)}});function G2t(e){return{models:MN(e.models),enums:MN(e.enums),types:MN(e.types)}}function MN(e){let r={};for(let{name:i,...n}of e)r[i]=n;return r}var Y2=(0,P8e.debug)("prisma:studio-pcw"),V2t=/^\s*datasource\s+([^\s]+)\s*{/m,H2t=/url *= *env\("(.*)"\)/,W2t=/url *= *"(.*)"/;async function z2t({schema:e,schemaPath:r,dmmf:i,datasourceProvider:n,previewFeatures:a,datasources:o,engineType:u,paths:c,directUrl:p,versions:l}){let f=e.match(V2t)?.[1]??"",g=e.match(H2t)?.[1]??null,v=e.match(W2t)?.[1]??null,{getPrismaClient:E,PrismaClientKnownRequestError:x,PrismaClientRustPanicError:S,PrismaClientInitializationError:C,PrismaClientValidationError:A}=require(`${c.prismaClient}/runtime/${u}`),O=Buffer.from(e,"utf-8").toString("base64"),I=(0,jN.createHash)("sha256").update(
Authentication failed against database server at `localhost`, the provided database credentials for `postgres` are not valid.

Please make sure to provide valid database credentials for the database server at `localhost`.
  
Query:
{
  "modelName": "User",
  "operation": "findMany",
  "args": {
    "take": 100,
    "skip": 0,
    "select": {
      "id": true,
      "name": true,
      "email": true
    }
  }
}

How I came to the conclusion had an authentication error?

After using some help from ChatGPT I found out that the error was in regards to authentication issues, more specifically:

Invalid Database Credentials: The error explicitly mentions that the database credentials for the postgres user are not valid. This means either the username, password, or both are incorrect in the context of accessing your PostgreSQL database.

This got me confused as my - POSTGRES_PASSWORD was the same within my compose.yaml and .env files

To double check that it was truly an authentication error I ran
npx prisma db push

And got this error

Error: P1000: Authentication failed against database server at `localhost`, the provided database credentials for `postgres` are not valid.

Please make sure to provide valid database credentials for the database server at `localhost`.

Solution

After some playing around I realised my password on pgAdmin was not the same as that in my project, so to fix this I did:

  1. Changed my - POSTGRES_PASSWORD and related fields within my compose.yaml and .env files to the same password that I have as my pgAdmin4 password

  2. Ran npx prisma db push, this confirmed that the authentication is working

Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "postgres", schema "public" at "localhost:5432"

Your database is now in sync with your Prisma schema. Done in 135ms

✔ Generated Prisma Client (v5.9.1) to .\node_modules\@prisma\client in 57ms
  1. Ran npx prisma studio and everything ran as it should

@gabrieldeleles
Copy link

I managed to resolve the issue I was facing. It turned out I was using a schema that differed from the one in my latest database push, which is likely why Prisma Studio wasn't recognizing it.

@suggy33
Copy link

suggy33 commented Mar 13, 2024

In my case I was using the .env.local file to load the environment variables, so installed the dotenv-cli as devDependency and then added this script to package.json file:

"scripts": {
    "studio": "dotenv -e .env.local -- pnpx prisma studio"
  }

@winterdelta
Copy link

Hello, did you prisma db push? I had the same error.

I'm relatively sure that this error is caused by the prisma dev (in this case... me!) updating the schema and pushing the change to git, e.g. via VSCode and reloading the Studio via pnpm prisma studio all without running the pnpm prisma db push command (in the case you are running on planetscale - pnpm prisma migrate if you aren't).

pnpm prisma db push resolved this issue for me.

@thienguen
Copy link

In my case, it was the uniqueness of the id field (constraint applied) that I manually seed it to the db.

So if you seed your data or manually input the id to it through studio, this will cause the studio to be confused since the id is supposed to be auto-generated.

Any attempt of creation will fail as it tries to start the id from 1, but found an entry already existed (from our manual input). It failed there.

  {
    "id": 0, <-- remove this id if you seed the data
    "content": "South ability no affect catch that area.",
    "published": true,
    "authorId": 6
  },

Or delete all data in the that collection you having trouble with, so it can restart the unique id

@AlexRixten
Copy link

I had the same problem and it was due to the fact that I used .env.local instead of .env, as soon as I returned the name everything worked, I will be glad if I helped you)

@kleydon
Copy link

kleydon commented Apr 28, 2024

Thanks @AlexRixten!

@Merigaz
Copy link

Merigaz commented May 2, 2024

In my case, it was the uniqueness of the id field (constraint applied) that I manually seed it to the db.

So if you seed your data or manually input the id to it through studio, this will cause the studio to be confused since the id is supposed to be auto-generated.

Any attempt of creation will fail as it tries to start the id from 1, but found an entry already existed (from our manual input). It failed there.

  {
    "id": 0, <-- remove this id if you seed the data
    "content": "South ability no affect catch that area.",
    "published": true,
    "authorId": 6
  },

Or delete all data in the that collection you having trouble with, so it can restart the unique id

In my case this was the problem, thank u

@0xCatPapa
Copy link

I had the same problem and it was due to the fact that I used .env.local instead of .env, as soon as I returned the name everything worked, I will be glad if I helped you)

I had this same issue and fixed it by using dotenv CLI via package.json

"scripts": {
    "local:migrate:postgres": "dotenv -e .env.local -- npx prisma migrate deploy",
    "local:migrate:init": "dotenv -e .env.local -- npx prisma migrate dev --name init",
    "local:prisma:studio": "dotenv -e .env.local -- npx prisma studio"
  }

@janpio
Copy link
Contributor

janpio commented Jun 7, 2024

Please, everyone commenting here or trying to, please oepn a new issue and include the full information you get behind "Show Details" of the error modal. Thank you.

@janpio janpio closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2024
@prisma prisma locked as off-topic and limited conversation to collaborators Jun 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. topic: "Prisma Client Error"
Projects
None yet
Development

No branches or pull requests