CLI-generated schema incompatible with email/password signup #1501

Closed
opened 2026-03-13 08:43:38 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @screenfluent on GitHub (Jul 15, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Bug Description

The schema generated by @better-auth/cli generate creates a name field marked as NOT NULL, but the email/password signup functionality doesn't provide a name value, causing database constraint violations.

Steps to Reproduce

  1. Generate schema using CLI:
    npx @better-auth/cli generate
    

Copy generated schema to your database schema file
Run migrations to create tables
Attempt email/password signup:
curl -X POST http://localhost:5173/api/auth/sign-up/email
-H "Content-Type: application/json"
-d '{"email": "test@example.com", "password": "secure123"}'

Expected Behavior

Email/password signup should work without requiring a name field.

Actual Behavior

{
"code": "FAILED_TO_CREATE_USER",
"message": "Failed to create user",
"details": {
"code": "SQLITE_CONSTRAINT_NOTNULL"
}
}

Root Cause

CLI generates:
name: text('name').notNull(), // Required
But email/password signup doesn't provide a name value, causing the database to reject the insert.

Workaround

Manually change the schema to make name optional:

name: text('name'), // Optional

Suggested Fix

The CLI should generate the name field as optional to match the library's runtime behavior, or the email/password signup should handle the required name field appropriately.

Current vs. Expected behavior

Expected Behavior

Email/password signup should work without requiring a name field.

Actual Behavior

{
"code": "FAILED_TO_CREATE_USER",
"message": "Failed to create user",
"details": {
"code": "SQLITE_CONSTRAINT_NOTNULL"
}
}

What version of Better Auth are you using?

1.3.0-beta.8

Provide environment information

- SvelteKit version: ^2.22.0
- Database: SQLite with Drizzle ORM
- Adapter: drizzle-adapter
- Plugins: sveltekitCookies()

Which area(s) are affected? (Select all that apply)

Backend

Auth config (if applicable)

export const auth = betterAuth({
    database: drizzleAdapter(db, {
        provider: "sqlite",
    }),
    emailAndPassword: {
        enabled: true, 
    },
    plugins: [
        sveltekitCookies()
    ]
});

Additional context

No response

Originally created by @screenfluent on GitHub (Jul 15, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce ## Bug Description The schema generated by `@better-auth/cli generate` creates a `name` field marked as `NOT NULL`, but the email/password signup functionality doesn't provide a name value, causing database constraint violations. ## Steps to Reproduce 1. Generate schema using CLI: ```bash npx @better-auth/cli generate Copy generated schema to your database schema file Run migrations to create tables Attempt email/password signup: curl -X POST http://localhost:5173/api/auth/sign-up/email \ -H "Content-Type: application/json" \ -d '{"email": "test@example.com", "password": "secure123"}' ## Expected Behavior Email/password signup should work without requiring a name field. ## Actual Behavior { "code": "FAILED_TO_CREATE_USER", "message": "Failed to create user", "details": { "code": "SQLITE_CONSTRAINT_NOTNULL" } } ## Root Cause CLI generates: name: text('name').notNull(), // ❌ Required But email/password signup doesn't provide a name value, causing the database to reject the insert. ## Workaround Manually change the schema to make name optional: name: text('name'), // ✅ Optional ## Suggested Fix The CLI should generate the name field as optional to match the library's runtime behavior, or the email/password signup should handle the required name field appropriately. ### Current vs. Expected behavior ## Expected Behavior Email/password signup should work without requiring a name field. ## Actual Behavior { "code": "FAILED_TO_CREATE_USER", "message": "Failed to create user", "details": { "code": "SQLITE_CONSTRAINT_NOTNULL" } } ### What version of Better Auth are you using? 1.3.0-beta.8 ### Provide environment information ```bash - SvelteKit version: ^2.22.0 - Database: SQLite with Drizzle ORM - Adapter: drizzle-adapter - Plugins: sveltekitCookies() ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "sqlite", }), emailAndPassword: { enabled: true, }, plugins: [ sveltekitCookies() ] }); ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 08:43:38 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 15, 2025):

Hi @screenfluent! I'm Dosu and I’m helping the better-auth team.

This is a known issue: the CLI-generated schema marks the name field as NOT NULL, but the email/password signup flow doesn't provide a name, causing a constraint error. The maintainers have acknowledged this and recommend either making the name field optional in your schema or auto-filling it with a placeholder value during signup if you don't collect a name from users. The requirement for name is enforced at both the API and schema level, and can't be disabled via config or plugins. This mismatch has been fixed in upcoming releases, so upgrading to the latest beta may resolve it for you. See discussion and issue for more details.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jul 15, 2025): <!-- Greeting --> Hi @screenfluent! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a known issue: the CLI-generated schema marks the name field as NOT NULL, but the email/password signup flow doesn't provide a name, causing a constraint error. The maintainers have acknowledged this and recommend either making the name field optional in your schema or auto-filling it with a placeholder value during signup if you don't collect a name from users. The requirement for name is enforced at both the API and schema level, and can't be disabled via config or plugins. This mismatch has been fixed in upcoming releases, so upgrading to the latest beta may resolve it for you. See [discussion](https://github.com/better-auth/better-auth/discussions/3222) and [issue](https://github.com/better-auth/better-auth/issues/2674) for more details. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/102be897-a680-4904-a258-7a41b301de38?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/102be897-a680-4904-a258-7a41b301de38?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/102be897-a680-4904-a258-7a41b301de38?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/102be897-a680-4904-a258-7a41b301de38?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/102be897-a680-4904-a258-7a41b301de38?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/102be897-a680-4904-a258-7a41b301de38?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/102be897-a680-4904-a258-7a41b301de38?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3394)
Author
Owner

@Kinfe123 commented on GitHub (Jul 17, 2025):

right now, the name is also a required field but we are working towards to make the fields more extendable and flexible. closing in favor of previous opened issue.

@Kinfe123 commented on GitHub (Jul 17, 2025): right now, the name is also a required field but we are working towards to make the fields more extendable and flexible. closing in favor of previous opened issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1501