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

FaunaAdapter : create_User fails because of native id constraints #12234

Open
SB17Codes opened this issue Nov 13, 2024 · 0 comments
Open

FaunaAdapter : create_User fails because of native id constraints #12234

SB17Codes opened this issue Nov 13, 2024 · 0 comments
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

@SB17Codes
Copy link

Adapter type

@auth/fauna-adapter

Environment

System:
OS: macOS 14.5
CPU: (8) arm64 Apple M2
Memory: 137.31 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.1 - ~/.nvm/versions/node/v20.12.1/bin/node
npm: 10.5.0 - ~/.nvm/versions/node/v20.12.1/bin/npm
Browsers:
Safari: 17.5
npmPackages:
@auth/fauna-adapter: ^3.7.3 => 3.7.3
next: 15.0.3 => 15.0.3
next-auth: ^5.0.0-beta.25 => 5.0.0-beta.25
react: 19.0.0-rc-66855b96-20241106 => 19.0.0-rc-66855b96-20241106

Reproduction URL

https://github.com/SB17Codes/faunaadapter-error.git

Describe the issue

I'm developing a web application using Next.js and implementing an authentication system with NextAuth.js and FaunaDB through the Fauna adapter. Despite following the official documentation for both NextAuth and the Fauna adapter, I'm encountering a critical error during the user authentication process.

adapter_createUser {
  "args": [
    {
      "id": "540bc67d-4e79-4b25-test",
      "name": "tes",
      "email": "test@gmail.com",
      "image": "https://lh3.googleusercontent.com/a/test=s96-c",
      "emailVerified": null
    }
  ]
}
[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: ConstraintFailureError: Failed to create document in collection `User`.
[auth][details]: {}
[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: ConstraintFailureError: Failed to create document in collection `User`.
[auth][details]: {}
[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: ConstraintFailureError: Failed to create document in collection `User`.
[auth][details]: {}
[auth][error] AdapterError: Read more at https://errors.authjs.dev#adaptererror
[auth][cause]: ConstraintFailureError: Failed to create document in collection `User`.
[auth][details]: {}

I've followed the documentation for the FaunaAdapter to the letter created the schemas for the necessary tables as indicated but after trying to debug the issue using the Fauna Dashboard I noticed that the id field is a reserved field in fauna but still we could create User documents using custom ids that we provide up to a certain length and then it would give us the following error:

User.create({
  id: "111111111111111111111111111111"
})

constraint_failure

error: Failed to create document in collection `User`.
constraint failures:
  id: Expected ID | String | Long, provided String
at *query*:1:12
  |
1 |   User.create({
  |  ____________^
2 | |   id: "111111111111111111111111111111"
3 | | })
  | |__^
  |

and since the id that the social providers return is usually a too long the create_User function from the adapter returns constraint error related to the id

How to reproduce

Set up the .env.local with the appropriate variables from FaunaDB and google OAuth app and run the application

Expected behavior

Create a User in the fauna database

@SB17Codes SB17Codes 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 Nov 13, 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
Development

No branches or pull requests

1 participant