Skip to content

Fix: Remove generateId: false to fix OTP email verification#56

Merged
vas3k merged 1 commit intovas3k:mainfrom
H1D:fix/otp-uuid-generation
Jan 12, 2026
Merged

Fix: Remove generateId: false to fix OTP email verification#56
vas3k merged 1 commit intovas3k:mainfrom
H1D:fix/otp-uuid-generation

Conversation

@H1D
Copy link
Copy Markdown
Contributor

@H1D H1D commented Jan 12, 2026

⚠️ I'm aware the project is now focused on self-hosted deployments and OTP is not that inportant, but this is a small fix that resolves OTP login.

Problem

OTP email verification fails with error: `invalid input syntax for type uuid` when Better Auth tries to create verification records using non-UUID strings as IDs.

Root Cause

Setting `advanced.generateId: false` in Better Auth config conflicts with the `email-otp` plugin. When `generateId: false`, Better Auth attempts to use email strings directly as UUIDs for verification records, causing PostgreSQL UUID validation errors.

According to Better Auth documentation, the `generateId: false` option should only be used when the database handles ID generation (e.g., auto-increment primary keys). For UUID-based schemas, Better Auth should generate UUIDs using `crypto.randomUUID()`.

Solution

Remove the `generateId: false` line from `lib/auth.ts`. This allows Better Auth to properly generate UUIDs for all records, including email verification entries.

Changes

  • Removed `generateId: false` from the `advanced` configuration block
  • No other changes required - the existing UUID schema works correctly with default Better Auth ID generation

Testing

  • ✅ OTP emails send successfully
  • ✅ OTP verification completes without UUID errors
  • ✅ User sessions created properly
  • ✅ Existing authentication flows unaffected

References

@H1D H1D marked this pull request as ready for review January 12, 2026 00:40
Removes the generateId: false setting from Better Auth config that was causing UUID generation errors when creating OTP verification records.

According to Better Auth documentation, generateId: false should only be used for auto-increment ID schemas. For UUID-based schemas, Better Auth should generate UUIDs using crypto.randomUUID().

This fixes the 'Failed to send the code' error during OTP email verification.
@H1D H1D force-pushed the fix/otp-uuid-generation branch from 04f9c4a to 30c0996 Compare January 12, 2026 00:42
Copy link
Copy Markdown
Owner

@vas3k vas3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙏

@vas3k vas3k merged commit f7cec37 into vas3k:main Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants