Cannot read property of undefined (reading 'modelName') despite declaring all modelNames. #258

Closed
opened 2026-03-13 07:40:01 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @ping-maxwell on GitHub (Nov 21, 2024).

Describe the bug
In my auth.ts I've declared modelNames for user, account, sesession & verification.
No type errors as it's what's expected.
However when signing up, I receive an error in the console:
image

To Reproduce

  • I'm using PlanetScale (MySQL) with Drizzle.
  • Using the DrizzleAdapter as follows:
drizzleAdapter(db, {
    provider: "mysql",
    schema: {
      privateUsers: schema.privateUsers,
      sessions: schema.sessions,
      accounts: schema.accounts,
      verifications: schema.verifications,
    },
  })
  • Custom set the modelName for each type:
{
 user: {
    modelName: "privateUsers",
    additionalFields: {
      agreedToPrivacy: { type: "boolean", required: true },
      agreedToTOS: { type: "boolean", required: true },
      recieveEmails: { type: "boolean", required: false, defaultValue: true },
      businessEmail: { type: "string", required: false },
      businessPhone: { type: "string", required: false },
      birthday: { type: "date", required: false },
      firstName: { type: "string", required: false },
      lastName: { type: "string", required: false },
    },
  },
  account: {
    modelName: "accounts",
  },
  session: {
    modelName: "sessions",
  },
  verification: {
    modelName: "verifications",
  },
}

Expected behavior
No errors regarding undefined ModelName considering I've defined it all as far as I'm aware.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser Arc - Chrome
  • Version:
    Arc Version 1.69.0 (55816)
    Chromium Engine Version 131.0.6778.70

Additional context
Note: When singing up, I do see a row being set on privateUsers, however no other tables received new rows.

Originally created by @ping-maxwell on GitHub (Nov 21, 2024). **Describe the bug** In my `auth.ts` I've declared modelNames for user, account, sesession & verification. No type errors as it's what's expected. However when signing up, I receive an error in the console: <img width="1151" alt="image" src="https://github.com/user-attachments/assets/2500db6f-5cbd-4ce0-a3a6-8393ab620acb"> **To Reproduce** * I'm using PlanetScale (MySQL) with Drizzle. * Using the DrizzleAdapter as follows: ```ts drizzleAdapter(db, { provider: "mysql", schema: { privateUsers: schema.privateUsers, sessions: schema.sessions, accounts: schema.accounts, verifications: schema.verifications, }, }) ``` * Custom set the modelName for each type: ```ts { user: { modelName: "privateUsers", additionalFields: { agreedToPrivacy: { type: "boolean", required: true }, agreedToTOS: { type: "boolean", required: true }, recieveEmails: { type: "boolean", required: false, defaultValue: true }, businessEmail: { type: "string", required: false }, businessPhone: { type: "string", required: false }, birthday: { type: "date", required: false }, firstName: { type: "string", required: false }, lastName: { type: "string", required: false }, }, }, account: { modelName: "accounts", }, session: { modelName: "sessions", }, verification: { modelName: "verifications", }, } ``` **Expected behavior** No errors regarding undefined ModelName considering I've defined it all as far as I'm aware. **Desktop (please complete the following information):** - OS: MacOS - Browser Arc - Chrome - Version: Arc Version 1.69.0 (55816) Chromium Engine Version 131.0.6778.70 **Additional context** Note: When singing up, I do see a row being set on `privateUsers`, however no other tables received new rows.
Author
Owner

@ping-maxwell commented on GitHub (Nov 21, 2024):

Tested canary better auth & canary react/react-dom, same error:
image

@ping-maxwell commented on GitHub (Nov 21, 2024): Tested canary better auth & canary react/react-dom, same error: <img width="1126" alt="image" src="https://github.com/user-attachments/assets/83c37d7c-1246-48f3-aa4b-bcb71b48395c">
Author
Owner

@grosenberg commented on GitHub (Jan 5, 2025):

@Multinite I am having what appears to be the same problem.

Could you please share your solution.

Thanks.

@grosenberg commented on GitHub (Jan 5, 2025): @Multinite I am having what appears to be the same problem. Could you please share your solution. Thanks.
Author
Owner

@ping-maxwell commented on GitHub (Jan 5, 2025):

@Multinite I am having what appears to be the same problem.

Could you please share your solution.

Thanks.

I'm on latest BetterAuth version and it works fine.
I will say that i have developed custom plugins explicitly for my additional fields.

@ping-maxwell commented on GitHub (Jan 5, 2025): > @Multinite I am having what appears to be the same problem. > > Could you please share your solution. > > Thanks. I'm on latest BetterAuth version and it works fine. I will say that i have developed custom plugins explicitly for my additional fields.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#258