#30310·Prisma

[Prisma 8 - MongoDB] - Polymorphic Collections give runtime error when extending with no fields

Author: jochemvanweeldeCreated Sep 15, 2026Updated Sep 15, 2026
Labelsbug/1-unconfirmedkind/bug

Package and version

8.0.0-rc.11

What happened?

When generating schema with Polymorphic Collections with model with no extra fields extended from base, will give this runtime error upon querying.

StructuredError: Contract structural validation failed: domain.namespaces.unbound.models.DealPartnerAttachment.fields must be an object (was missing)

What did you expect to happen?

One of these options:

  • Generation error: Disallowing extending model with no extra fields
  • No error on query: Allowing the generation of a discriminator type where only the base fields are available, with no extra fields. (See reproduction for example)

Minimal reproduction

Given this example model of a document.

prisma
model Document {
  id        ObjectId @id @map("_id")
  createdAt DateTime
  updatedAt DateTime

  blobUrl String

  @@map("documents")
}

Let's say we have three different documents: Quote, Invoice and Generic. Both Quote and Invoice extend the base model with quotationNumber and invoiceNumber respectively. Generic has no extra fields. Doing this with the new discriminator feature is not possible:

prisma
model Document {
  id        ObjectId @id @map("_id")
  createdAt DateTime
  updatedAt DateTime

  blobUrl String

   type String

  @@discriminator(type)
  @@map("documents")
}

model Quote {
  quotationNumber String

  @@base(DealAttachment, "QUOTE")
}

model Invoice {
  invoiceNumber String

  @@base(DealAttachment, "INVOICE")
}

The above code snippet will generate a type where Document.type can only be QUOTE or INVOICE. adding the Generic document type:

prisma
model GenericDocument {
  // No extended fields

  @@base(DealAttachment, "GENERIC")
}

This will correctly generate the schema but will result in a run time contract validation error: StructuredError: Contract structural validation failed: domain.namespaces.unbound.models.Document.fields must be an object (was missing). The generated type is correct.

Environment

MongoDB 8.0.29 Atlas Node 24.15.0 NextJS 16.3

Additional context

No response