You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tayloraucoin opened this issue
Sep 4, 2024
· 1 comment
Labels
adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
I am encountering a TypeError: Cannot read properties of undefined (reading 'findUnique') during the OAuth callback with Google. The error occurs specifically when attempting to retrieve the user by account after a successful OAuth callback. I am able to see the account returned by Google in the log above the error.
Interestingly, my company has this same setup in a sister application. The versions are quite similar but not exact. However, this problem does not occur in that application. Here are the version details for both setups:
The Prisma client is confirmed to be working elsewhere in the application. Additionally, the adapter in next-auth has a try-catch block that confirms its successful initialization.
What I’ve tried so far:
I’ve referenced #7967 which suggests using @@Map in Prisma models to fix this issue. However, using @@Map renames the tables to lowercase, leading to case sensitivity issues with Prisma's operations. I also posted a discussion before seeing that this may likely be a bug. #11763
[next-auth][error][OAUTH_CALLBACK_HANDLER_ERROR]
https://next-auth.js.org/errors#oauth_callback_handler_error Cannot read properties of undefined (reading 'findUnique')
at getUserByAccount (webpack-internal:///(rsc)/./node_modules/@next-auth/prisma-adapter/dist/index.js:211:45)
Expected behavior:
How to reproduce
In my provided repo, I have included all the code that I am using.
There appears to be some convention differences causing the issue. The application throws an error: Cannot read properties of undefined (reading 'map') at setEnvDefaults, which seems unique to the provided example repo. I assume this can be resolved quickly, but aside from that, everything should run as expected.
Please navigate to the /test-oauth-sign-up URL and click the Google OAuth button. You will need to either adjust the callback URL within the ./components/app/auth/SignUpForm.tsx file or modify your Google OAuth accepted redirect URLs.
Once you select a Gmail account and approve the permissions, the redirect back in the callback process breaks as it cannot find the Prisma entity to run the query on.
Expected behavior
The OAuth callback should correctly retrieve the user from the database using findUnique without throwing an error.
The text was updated successfully, but these errors were encountered:
tayloraucoin
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
Sep 4, 2024
adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Adapter type
@auth/prisma-adapter
Environment
Reproduction URL
https://github.com/tayloraucoin/next-auth-prisma-undefined-bug
Describe the issue
I am encountering a
TypeError: Cannot read properties of undefined (reading 'findUnique')
during the OAuth callback with Google. The error occurs specifically when attempting to retrieve the user by account after a successful OAuth callback. I am able to see the account returned by Google in the log above the error.Interestingly, my company has this same setup in a sister application. The versions are quite similar but not exact. However, this problem does not occur in that application. Here are the version details for both setups:
Ours:
Sister App:
The Prisma client is confirmed to be working elsewhere in the application. Additionally, the adapter in next-auth has a try-catch block that confirms its successful initialization.
What I’ve tried so far:
I’ve referenced #7967 which suggests using @@Map in Prisma models to fix this issue. However, using @@Map renames the tables to lowercase, leading to case sensitivity issues with Prisma's operations. I also posted a discussion before seeing that this may likely be a bug. #11763
I’ve also followed the official Prisma setup documentation, but this error persists.
Models:
Error Logs:
How to reproduce
In my provided repo, I have included all the code that I am using.
There appears to be some convention differences causing the issue. The application throws an error:
Cannot read properties of undefined (reading 'map') at setEnvDefaults
, which seems unique to the provided example repo. I assume this can be resolved quickly, but aside from that, everything should run as expected.Please navigate to the
/test-oauth-sign-up
URL and click the Google OAuth button. You will need to either adjust the callback URL within the./components/app/auth/SignUpForm.tsx
file or modify your Google OAuth accepted redirect URLs.Once you select a Gmail account and approve the permissions, the redirect back in the callback process breaks as it cannot find the Prisma entity to run the query on.
Expected behavior
The OAuth callback should correctly retrieve the user from the database using findUnique without throwing an error.
The text was updated successfully, but these errors were encountered: