Prisma 6.6.0: Unable to use Prisma.JsonNull and Prisma.DbNull due to "We could not serialize [object

I have hit a problem that is affecting both dev and prod... on a Friday night. Any help on the GH issue would be helpful: https://github.com/prisma/prisma/issues/26987
GitHub
Prisma 6.6.0: Unable to use Prisma.JsonNull and Prisma.DbNull due t...
Bug description After updating to Prisma 6.6.0 i have been facing this issue. Severity ⚠️ Major: Breaks core functionality (e.g., migrations fail) Reproduction Create schema with optional Json fiel...
3 Replies
Prisma AI Help
You chose to compile with the bot. One moment while I piece together your answer… I can see you're having issues with Prisma 6.6.0 related to Prisma.JsonNull and Prisma.DbNull. Based on the knowledge sources, this appears to be a known issue in Prisma 6.6.0 with the new generator. The issue is related to type checking failures with the client generated by the new generator. Specifically, there are errors with the DbNull, JsonNull, and AnyNull properties in the generated client:
error TS4094: Property '_brand_DbNull' of exported anonymous class type may not be private or protected.
error TS4094: Property '_brand_DbNull' of exported anonymous class type may not be private or protected.
This is happening because the generated client contains code that violates TypeScript constraints, particularly when using "composite": true in your tsconfig.json. A temporary workaround that has been suggested is to create a script that modifies the generated client after Prisma generates it:
const fs = require('fs');
const path = require('path');

const filePath = path.join(__dirname, '../generated/client/client.ts');

let content = fs.readFileSync(filePath, 'utf8');

content = content.replace(
/export const (DbNull|JsonNull|AnyNull) = runtime\.objectEnumValues\.instances\.\1/g,
'export const $1 = NullTypes.$1',
);

fs.writeFileSync(filePath, content);

console.log('✅ Prisma types have been successfully modified.');
const fs = require('fs');
const path = require('path');

const filePath = path.join(__dirname, '../generated/client/client.ts');

let content = fs.readFileSync(filePath, 'utf8');

content = content.replace(
/export const (DbNull|JsonNull|AnyNull) = runtime\.objectEnumValues\.instances\.\1/g,
'export const $1 = NullTypes.$1',
);

fs.writeFileSync(filePath, content);

console.log('✅ Prisma types have been successfully modified.');
Then add this to your package.json:
{
"scripts": {
"prisma:generate": "pnpm prisma generate && node scripts/fix-prisma-types.js"
}
}
{
"scripts": {
"prisma:generate": "pnpm prisma generate && node scripts/fix-prisma-types.js"
}
}
This issue has been reported in GitHub issue #26841 and GitHub issue #26902. Another simpler but less ideal workaround is to add @ts-nocheck at the top of the client.ts file, though this would need to be done after each file generation. I hope this helps with your Friday night emergency! GitHub: prisma/prisma 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurul4d ago
Hey! Does this error occur on Prisma version 6.5.0 as well?
antonio
antonioOP21h ago
No, it startted to happen once I have updated from 6.5 to 6.6 So it seems to be 6.6 issue @Nurul (Prisma) instead of JsonNull/DbNull can i just use null for the time while you fix this in the next relese? @Nurul any update?

Did you find this page helpful?