Package and version
@internal/mongo-contract-psl — prisma/prisma main @ 10c57bc
What happened?
This is a re-file of prisma/prisma-next#1070 after Prisma Next development moved to prisma/prisma.
The issue still reproduces on the latest main.
For a Mongo polymorphic variant with no fields of its own, the PSL interpreter correctly produces fields: {}. Generic contract canonicalization then removes that empty object.
The resulting contract is invalid because fields is required by the Mongo contract schema.
Observed result:
BEFORE_NOTE={"fields":{},"relations":{},"storage":{"collection":"posts"},"base":{"namespace":"__unbound__","model":"Post"}}
BEFORE_HAS_FIELDS=true
AFTER_NOTE={"base":{"model":"Post","namespace":"__unbound__"},"relations":{},"storage":{"collection":"posts"}}
AFTER_HAS_FIELDS=false
CONTRACT_VALID=false
VALIDATION_ERROR=domain.namespaces.__unbound__.models.Note.fields must be an object (was missing)
What did you expect to happen?
Canonicalization should preserve the required empty fields object for a field-less variant.
The canonicalized contract should therefore retain:
and pass MongoContractSchema validation.
Minimal reproduction
Using the current Mongo PSL interpreter, canonicalizer, and contract schema with:
model Post {
id ObjectId @id @map("_id")
title String
kind String
@@discriminator(kind)
@@map("posts")
}
model Note {
@@base(Post, "note")
}
- Interpret the schema through the Mongo PSL interpreter.
- Verify that
Note.fields is {}.
- Canonicalize the resulting contract.
- Inspect
Note.fields again.
- Validate the canonicalized contract with
MongoContractSchema.
Current result:
Before canonicalization: Note.fields exists and equals {}
After canonicalization: Note.fields is missing
MongoContractSchema validation: fails
Environment
- Prisma repository:
prisma/prisma
- Commit:
10c57bcca34f1bd10ddd01571f82fa9ce4280841
- Branch:
main
- Node: 24.19.0
- OS: Fedora Linux
- Package manager: pnpm
- Target database family: MongoDB
Additional context
Original report: prisma/prisma-next#1070
The issue was closed because the prisma/prisma-next repository is being archived, not because the bug was fixed.
I re-tested this against the latest prisma/prisma main, where it still reproduces.
The current canonicalizer has preservation handling for required empty model relations and storage objects, but no equivalent handling for fields.
A PR with a fix and regression coverage is already open: #30003
Package and version
@internal/mongo-contract-psl — prisma/prisma main @ 10c57bc
What happened?
This is a re-file of prisma/prisma-next#1070 after Prisma Next development moved to
prisma/prisma.The issue still reproduces on the latest
main.For a Mongo polymorphic variant with no fields of its own, the PSL interpreter correctly produces
fields: {}. Generic contract canonicalization then removes that empty object.The resulting contract is invalid because
fieldsis required by the Mongo contract schema.Observed result:
What did you expect to happen?
Canonicalization should preserve the required empty
fieldsobject for a field-less variant.The canonicalized contract should therefore retain:
{ "fields": {} }and pass
MongoContractSchemavalidation.Minimal reproduction
Using the current Mongo PSL interpreter, canonicalizer, and contract schema with:
Note.fieldsis{}.Note.fieldsagain.MongoContractSchema.Current result:
Environment
prisma/prisma10c57bcca34f1bd10ddd01571f82fa9ce4280841mainAdditional context
Original report: prisma/prisma-next#1070
The issue was closed because the
prisma/prisma-nextrepository is being archived, not because the bug was fixed.I re-tested this against the latest
prisma/prismamain, where it still reproduces.The current canonicalizer has preservation handling for required empty model
relationsandstorageobjects, but no equivalent handling forfields.A PR with a fix and regression coverage is already open: #30003