Fix: Remove generateId: false to fix OTP email verification#56
Merged
vas3k merged 1 commit intovas3k:mainfrom Jan 12, 2026
Merged
Fix: Remove generateId: false to fix OTP email verification#56vas3k merged 1 commit intovas3k:mainfrom
vas3k merged 1 commit intovas3k:mainfrom
Conversation
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.
04f9c4a to
30c0996
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Testing
References