When working with Prisma & Planetscale, debugging Null/ Unique Constraint violations lead to obscure errors especially when using nested writes. The error message be missed and this is the filtered error from Planetscale (and passed through to Prisma Client):
Null constraint violation on the (not available)
The field that violates the constraint is not available from Planetscale.
Original Prisma Client error
{"type":"PrismaClientKnownRequestError","message":"\nInvalid `prisma.workflowRun.create()`
invocation:\n\n\nNull constraint violation on the (not available)","stack":"Error: \nInvalid `prisma.workflowRun.create()` invocation:\n\n\nNull constraint violation on the (not available)\n at pn.handleRequestError
(/var/task/node_modules/.pnpm/@prisma+client@4.13.0_prisma@4.13.0/node_modules/@prisma/client/runtime/library.js:176:6477)\n at pn.handleAndLogRequestError
(/var/task/node_modules/.pnpm/@prisma+client@4.13.0_prisma@4.13.0/node_modules/@prisma/client/runtime/library.js:176:5907)
\n at pn.request (/var/task/node_modules/.pnpm/@prisma+client@4.13.0_prisma@4.13.0/node_modules/@prisma/client/runtime/library.js:176:5786)
\n at t._request (/var/task/node_modules/.pnpm/@prisma+client@4.13.0_prisma@4.13.0/node_modules/@prisma/client/runtime/library.js:179:10484)
\n at action (/var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:188:25)\n at Object.callRouteActionRR (/var/task/node_modules/.pnpm/@remix-run+server-runtime@1.16.0/node_modules/@remix-run/server-runtime/dist/data.js:24:16)\n at callLoaderOrAction (/var/task/node_modules/.pnpm/@remix-run+router@1.6.0/node_modules/@remix-run/router/dist/router.cjs.js:3817:16)\n at submit (/var/task/node_modules/.pnpm/@remix-run+router@1.6.0/node_modules/@remix-run/router/dist/router.cjs.js:3256:16)\n at queryImpl (/var/task/node_modules/.pnpm/@remix-run+router@1.6.0/node_modules/@remix-run/router/dist/router.cjs.js:3206:22)\n at Object.queryRoute (/var/task/node_modules/.pnpm/@remix-run+router@1.6.0/node_modules/@remix-run/router/dist/router.cjs.js:3165:18)",
"code":"P2011","clientVersion":"4.13.0","meta":{"constraint":null}},"msg":"An unexpected error occured"}
When working with Prisma & Planetscale, debugging Null/ Unique Constraint violations lead to obscure errors especially when using nested writes. The error message be missed and this is the filtered error from Planetscale (and passed through to Prisma Client):
The field that violates the constraint is not available from Planetscale.
Original Prisma Client error
Ideally, this would go up on this page: https://www.prisma.io/docs/guides/database/planetscale