47ng / 47ng/prisma-field-encryption

Prisma 6.16.0 — `dmmf` shape changed: `documentation` missing and field-encryption breaks in `prisma-client-js`

Aperta
#143 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
306
Fork
40
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Starting with Prisma **v6.16.0**, Prisma appears to have removed its Rust dependency.
Reference: [https://github.com/prisma/prisma/releases/tag/6.16.0](https://github.com/prisma/prisma/releases/tag/6.16.0)

After upgrading, the shape of `dmmf` returned by the new client seems to have changed. As a result:

* Zod validation fails because `isList`, `isUnique`, and `isId` are no longer present on fields.
* `documentation` also appears to be missing or no longer accessible via `dmmf`.

I patched the package to avoid the Zod errors, but I still cannot load `documentation`. Because of this, field encryption no longer works.

This problem occurs when using **`prisma-client-js`** (not `prisma-client`). `prisma-client` recommends using `@prisma/internals` as a workaround, but including `@prisma/internals` pulls a WASM file into the package and that causes errors in some web frameworks (bundling/runtime issues).

## Steps to reproduce

1. Upgrade Prisma to `6.16.0` (or later).
2. Generate the client and inspect `dmmf` from `prisma-client-js`.
3. Attempt to read `field.documentation` (or run code that expects `isList`, `isUnique`, `isId`).
4. Observe Zod validation / field-encryption code failing and `documentation` being unavailable.

## Actual behavior

* `dmmf` no longer contains `isList`, `isUnique`, or `isId` for fields.
* `documentation` is not accessible via `dmmf`.
* Workarounds that import `@prisma/internals` introduce WASM which breaks bundling/runtime in some web frameworks.
* Field encryption fails because it cannot determine which fields have documentation/metadata.

## Workarounds tried

* Rewrote the package to bypass the missing `isList`/`isUnique`/`isId` checks — still cannot access `documentation`.
* Using `@prisma/internals` (suggested by `prisma-client`) — this causes errors in some web frameworks due to the WASM file being included.

## Example

dmmf
```json
{
"datamodel":{
"models":[
{
"name":"User",
"fields":[
{
"name":"id",
"kind":"scalar",
"type":"String"
},
{
"name":"name",
"kind":"scalar",
"type":"String"
},
{
"name":"email",
"kind":"scalar",
"type":"String"
},
{
"name":"emailVerified",
"kind":"scalar",
"type":"Boolean"
},
{
"name":"image",
"kind":"scalar",
"type":"String"
},
{
"name":"role",
"kind":"scalar",
"type":"String"
},
{
"name":"banned",
"kind":"scalar",
"type":"Boolean"
},
{
"name":"banReason",
"kind":"scalar",
"type":"String"
},
{
"name":"banExpires",
"kind":"scalar",
"type":"DateTime"
},
{
"name":"stripeCustomerId",
"kind":"scalar",
"type":"String"
},
{
"name":"chatwootSourceId",
"kind":"scalar",
"type":"String"
},
{
"name":"createdAt",
"kind":"scalar",
"type":"DateTime"
},
{
"name":"updatedAt",
"kind":"scalar",
"type":"DateTime"
}
]
}
]
}
}
```

schema.prisma
```prisma
model User {
id String @id
name String
email String @unique
emailVerified Boolean
image String?
role String?
banned Boolean?
banReason String?
banExpires DateTime?
stripeCustomerId String?
chatwootSourceId String?
createdAt DateTime
updatedAt DateTime
}
```

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

The issue is about changes in Prisma 6.16.0's dmmf shape affecting field encryption. Start by examining the prisma-field-encryption source code, particularly how it accesses dmmf metadata like field.documentation, isList, isUnique, and isId. Compare the dmmf output from Prisma versions before and after 6.16.0. Look for alternative ways to retrieve the needed metadata, possibly via @prisma/internals or other Prisma APIs, while avoiding WASM bundling issues. Test changes with a sample Prisma schema to ensure field encryption works again.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
typescript
Ambito
backend, databases
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.