Skip to content

strictUndefinedChecks does not work with query extensions #25845

@georgewitteman

Description

@georgewitteman

Bug description

When using the $allModels.$allOperations query extension, any usages of Prisma.skip cause an error to be thrown.

How to reproduce

  1. Set Prisma.skip in a create query for a prisma client with query extensions
  2. Running the file will trigger an error like this:
PrismaClientValidationError: 
Invalid `prisma.employee.create()` invocation in
/tmp/tmp.MOsQACwvAB/2024-12-12T233959/index.js:20:17

  17         }
  18     }
  19 });
→ 20 prisma.employee.create({
       data: {
         email: "0.19827359060498662@example.com",
         name: {}
               ~~
       }
     })

Argument `name`: Invalid value provided. Expected String or Null, provided Object.
    at En (/tmp/tmp.MOsQACwvAB/2024-12-12T233959/node_modules/@prisma/client/runtime/library.js:29:1363)
    at Mn.handleRequestError (/tmp/tmp.MOsQACwvAB/2024-12-12T233959/node_modules/@prisma/client/runtime/library.js:121:6981)
    at Mn.handleAndLogRequestError (/tmp/tmp.MOsQACwvAB/2024-12-12T233959/node_modules/@prisma/client/runtime/library.js:121:6663)
    at Mn.request (/tmp/tmp.MOsQACwvAB/2024-12-12T233959/node_modules/@prisma/client/runtime/library.js:121:6370)
    at async l (/tmp/tmp.MOsQACwvAB/2024-12-12T233959/node_modules/@prisma/client/runtime/library.js:130:9633) {
  clientVersion: '6.0.1'
}

Expected behavior

An error is not thrown

Prisma information

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["strictUndefinedChecks"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Employee {
  id    String @id @default(cuid())
  name  String?
  email String @unique
}
const prisma = new PrismaClient().$extends({
    query: {
        $allModels: {
          // Example query extension that does nothing
          $allOperations: async (params) => params.query(params.args),
        }
    }
});

prisma.employee.create({ data: { email: `${Math.random()}@example.com`, name: Prisma.skip } }).then((result) => {
    console.log(result)
}).catch((error) => {
    console.error(error)
})

Environment & setup

  • OS: Debian
  • Database: PostgreSQL
  • Node.js version: v20.18.0

Prisma Version

Environment variables loaded from .env
prisma                  : 6.0.1
@prisma/client          : 6.0.1
Computed binaryTarget   : debian-openssl-1.1.x
Operating System        : linux
Architecture            : x64
Node.js                 : v20.18.0
Query Engine (Node-API) : libquery-engine 5dbef10bdbfb579e07d35cc85fb1518d357cb99e (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Schema Engine           : schema-engine-cli 5dbef10bdbfb579e07d35cc85fb1518d357cb99e (at node_modules/@prisma/engines/schema-engine-debian-openssl-1.1.x)
Schema Wasm             : @prisma/prisma-schema-wasm 5.23.0-27.5dbef10bdbfb579e07d35cc85fb1518d357cb99e
Default Engines Hash    : 5dbef10bdbfb579e07d35cc85fb1518d357cb99e
Studio                  : 0.503.0
Preview Features        : strictUndefinedChecks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions