Setting defaultValue: false to boolean additional field doesn't set a default value #1756

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

Originally created by @0-BSCode on GitHub (Aug 22, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create vanilla auth server
  2. Extend the user schema with an additional field of type boolean
  3. Set the defaultValue of the additional boolean field to false
  4. Run the CLI to generate the schema

Current vs. Expected behavior

Current Behavior
The generated additional boolean field doesn't have a default value set.

Image

Current workaround is to set defaultValue: () => false, but I expected a behavior like the one below.

Expected Behavior
The generated additional boolean field should have a default value of false, similar to how setting defaultValue: true generates a default value of true (see below for reference)

Image

What version of Better Auth are you using?

1.3.7

System info

System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 AMD Ryzen 7 5800HS with Radeon Graphics
    Memory: 3.47 GB / 23.41 GB
  Browsers:
    Edge: Chromium (139.0.3405.86)
    Internet Explorer: 11.0.26100.1882

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

Backend

Auth config (if applicable)

// See above

Additional context

No response

Originally created by @0-BSCode on GitHub (Aug 22, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create vanilla auth server 2. Extend the `user` schema with an additional field of type `boolean` 3. Set the `defaultValue` of the additional boolean field to `false` 4. Run the CLI to generate the schema ### Current vs. Expected behavior **Current Behavior** The generated additional boolean field doesn't have a default value set. <img width="2048" height="683" alt="Image" src="https://github.com/user-attachments/assets/4b21f234-b5d7-46fc-b9b5-5ddfce5271fb" /> Current workaround is to set `defaultValue: () => false`, but I expected a behavior like the one below. **Expected Behavior** The generated additional boolean field should have a default value of `false`, similar to how setting `defaultValue: true` generates a default value of `true` (see below for reference) <img width="2048" height="690" alt="Image" src="https://github.com/user-attachments/assets/6f854f6b-c9b2-4dd6-8e88-9f0e0780fb6b" /> ### What version of Better Auth are you using? 1.3.7 ### System info ```bash System: OS: Windows 11 10.0.26100 CPU: (16) x64 AMD Ryzen 7 5800HS with Radeon Graphics Memory: 3.47 GB / 23.41 GB Browsers: Edge: Chromium (139.0.3405.86) Internet Explorer: 11.0.26100.1882 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript // See above ``` ### Additional context _No response_
GiteaMirror added the bug label 2026-03-13 09:01:16 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 22, 2025):

This is a known bug in Better Auth v1.3.7: setting defaultValue: false for a boolean additional field does not set the default value in the generated schema because the code checks for truthy values and skips false unless it explicitly checks for undefined. This has been fixed in a later version (after July 2025), where the schema generation logic now correctly assigns false as a default value if specified (details). Until you upgrade, the best workaround is to use defaultValue: () => false, which you already found.

To reply, just mention @dosu.


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

@dosubot[bot] commented on GitHub (Aug 22, 2025): <!-- Answer --> This is a known bug in Better Auth v1.3.7: setting `defaultValue: false` for a boolean additional field does not set the default value in the generated schema because the code checks for truthy values and skips `false` unless it explicitly checks for `undefined`. This has been fixed in a later version (after July 2025), where the schema generation logic now correctly assigns `false` as a default value if specified ([details](https://github.com/better-auth/better-auth/pull/3439)). Until you upgrade, the best workaround is to use `defaultValue: () => false`, which you already found. <!-- 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/d6587cdd-ae5f-43ee-871a-0ebfd56fea44?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/d6587cdd-ae5f-43ee-871a-0ebfd56fea44?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/d6587cdd-ae5f-43ee-871a-0ebfd56fea44?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/d6587cdd-ae5f-43ee-871a-0ebfd56fea44?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/d6587cdd-ae5f-43ee-871a-0ebfd56fea44?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/d6587cdd-ae5f-43ee-871a-0ebfd56fea44?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/d6587cdd-ae5f-43ee-871a-0ebfd56fea44?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&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/4158)
Author
Owner

@Kinfe123 commented on GitHub (Aug 23, 2025):

This lines makes sure to get the defaultValue of boolean and resolves them properly make sure to update to latest beta to make get this fixed.

@Kinfe123 commented on GitHub (Aug 23, 2025): This [lines](https://github.com/better-auth/better-auth/blob/c45ad901ce8a6159664860e54d3260bc4a56c665/packages/cli/src/generators/drizzle.ts#L151C8-L154C11) makes sure to get the defaultValue of boolean and resolves them properly make sure to update to latest beta to make get this fixed.
Author
Owner

@raj457036 commented on GitHub (Aug 26, 2025):

It doesn't work when the default value is false.

@raj457036 commented on GitHub (Aug 26, 2025): It doesn't work when the default value is false.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1756