Skip to content

A Mongo contract written in PSL and the same contract written in TypeScript get different storage hashes #30464

Open

Description

@wmadden-electric

What a user sees. Two Mongo contracts that describe the same collections, one authored in PSL and one with the TypeScript builder, never share a storageHash. The PSL interpreter derives a $jsonSchema validator for each collection and hashes a storage projection that includes it; the TypeScript builder derives no validator and hashes a different projection. So a project that moves between the two authoring styles sees its storage hash change, and db verify / db sign treat the database as out of date, although nothing about the collections changed. It also means a TypeScript-authored contract gets no collection validator at all.

Where. packages/2-mongo-family/2-authoring/contract-psl/src/interpreter.ts (validator derivation and storage building through buildMongoStorage) against packages/2-mongo-family/2-authoring/contract-ts/src/contract-builder.ts (its own storage construction and computeStorageHash).

Likely fix. Build TypeScript-authored storage through the same buildMongoStorage in @internal/mongo-contract that the PSL interpreter and the Prisma 6 reader use, including validator derivation. This re-hashes every TypeScript-authored Mongo contract, so it needs an upgrade instruction to re-emit and re-sign. See also the issue about the TypeScript builder's own enum encoding and storage hashing.

Where it came from. Recorded during #30403.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions