Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrismaAdapter is broken with new "strictUndefinedChecks" preview feature #11944

Closed
petergoldstein opened this issue Oct 1, 2024 · 0 comments · Fixed by #11952
Closed

PrismaAdapter is broken with new "strictUndefinedChecks" preview feature #11944

petergoldstein opened this issue Oct 1, 2024 · 0 comments · Fixed by #11952
Labels
adapters Changes related to the core code concerning database adapters bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@petergoldstein
Copy link
Contributor

Adapter type

@auth/prisma-adapter

Environment

 System:
    OS: macOS 14.6.1
    CPU: (12) arm64 Apple M2 Pro
    Memory: 73.50 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - /opt/homebrew/opt/node@20/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.8.2 - /opt/homebrew/opt/node@20/bin/npm
    pnpm: 8.14.0 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 129.0.6668.71
    Safari: 17.6
  npmPackages:
    @auth/prisma-adapter: ^2.5.3 => 2.5.3 
    next: ^14.2.13 => 14.2.13 
    next-auth: ^4.24.8 => 4.24.8 
    react: ^18.2.0 => 18.3.1 

Reproduction URL

https://github.com/tbd

Describe the issue

When using the new "strictUndefinedChecks" prisma preview feature, NextAuth generates an error when creating a user that has attributes that are not set in the data received from the provider

Invalid value for argument `data`: explicitly `undefined` values are not allowed. {
  message: '\n' +
    'Invalid `prisma.user.create()` invocation:\n' +
    '\n' +
    '{\n' +
    '  data: {\n' +
    '    name: "Goldstein, Peter",\n' +
    '    email: "[email protected]",\n' +
    '    image: undefined,\n' +
    '           ~~~~~~~~~\n' +
    '    emailVerified: null\n' +
    '  }\n' +
    '}\n' +
    '\n' +
    'Invalid value for argument `data`: explicitly `undefined` values are not allowed.',
  stack: 'PrismaClientValidationError: \n' +
    'Invalid `prisma.user.create()` invocation:\n' +
    '\n' +
    '{\n' +
    '  data: {\n' +
    '    name: "Goldstein, Peter",\n' +
    '    email: "[email protected]",\n' +
    '    image: undefined,\n' +
    '           ~~~~~~~~~\n' +
    '    emailVerified: null\n' +
    '  }\n' +
    '}\n' +
    '\n' +
    'Invalid value for argument `data`: explicitly `undefined` values are not allowed.\n' +
    '    at Dn (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:114:8082)\n' +
    '    at e.throwValidationError (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:114:13383)\n' +
    '    at ml (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:114:12142)\n' +
    '    at dl (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:114:11616)\n' +
    '    at ml (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:114:12085)\n' +
    '    at Dr (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:114:9214)\n' +
    '    at pl (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:114:9079)\n' +
    '    at /Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:130:10186\n' +
    '    at Object.runInChildSpan (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:121:1519)\n' +
    '    at t._executeRequest (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:130:10165)\n' +
    '    at fa (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:30:5477)\n' +
    '    at l (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:130:9639)\n' +
    '    at /Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:130:9933\n' +
    '    at AsyncResource.runInAsyncScope (node:async_hooks:206:9)\n' +
    '    at /Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:130:9913\n' +
    '    at Object.runInChildSpan (/Users/peter.goldstein/Development/octo-source/hearst-assistant-4/node_modules/@prisma/client/runtime/library.js:121:1519)\n' +

How to reproduce

  1. In a Prisma application, using a recent (5.20.0+) prisma engine, enable the "strictUndefinedChecks" previewFeature in the schema definition. Set something like:

generator client {
provider = "prisma-client-js"
previewFeatures = ["strictUndefinedChecks"]
binaryTargets = ["native", "debian-openssl-3.0.x"]
}

in the 'prisma/schema.prisma` file.

  1. Set up NextAuth with Okta (or any other provider) that has an optional attribute. In this case image
  2. Authenticate as a user without an image
  3. User record creation will fail

Expected behavior

In step 4, user creation should succeed

@petergoldstein petergoldstein added adapters Changes related to the core code concerning database adapters bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. labels Oct 1, 2024
petergoldstein added a commit to octo-source/next-auth that referenced this issue Oct 1, 2024
petergoldstein added a commit to octo-source/next-auth that referenced this issue Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adapters Changes related to the core code concerning database adapters bug Something isn't working triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
1 participant