[GH-ISSUE #7127] Type inconsistency: rememberMe is string in signIn but boolean in signUp #19368

Closed
opened 2026-04-15 18:23:10 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @jigz on GitHub (Jan 5, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/7127

Originally assigned to: @bytaesu on GitHub.

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Setup Better-Auth
  2. Add OpenAPI plugin

Current vs. Expected behavior

Related: https://github.com/better-auth/better-auth/issues/3987

Current:
openapi generator is defaulting to string when type is missing resulting in type inconsistency
a4a388d6f5/packages/better-auth/src/plugins/open-api/generator.ts (L84)

d343b34cf6/packages/better-auth/src/plugins/open-api/snapshots/open-api.test.ts.snap#L4003-L4006
d343b34cf6/packages/better-auth/src/plugins/open-api/snapshots/open-api.test.ts.snap#L3407-L3413

Image

Expected:

  • Detect correct type for rememberMe
  • Remove the dangerous fallback type

What version of Better Auth are you using?

1.4.10

System info

{
  "system": {
    "platform": "win32",
    "arch": "x64",
    "version": "Windows 11 Home",
    "release": "10.0.26200",
    "cpuCount": 24,
    "cpuModel": "AMD Ryzen AI 9 HX 370 w/ Radeon 890M           ",
    "totalMemory": "23.62 GB",
    "freeMemory": "3.85 GB"
  },
  "node": {
    "version": "v22.14.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.27.0"
  },
  "frameworks": null,
  "databases": null,
  "betterAuth": {
    "version": "Unknown",
    "config": null
  }
}

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

Backend

Auth config (if applicable)

import { expo } from "@better-auth/expo";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import {
  admin,
  openAPI,
} from "better-auth/plugins";
import db from "@/db";
import { prefixTableName } from "@/db/schema";
import packageJson from "./../../package.json" with { type: "json" };

export const auth = betterAuth({
  database: drizzleAdapter(db, {
    provider: "pg",
  }),
  appName: packageJson.name,
  user: {
    modelName: prefixTableName("betterauth_user"),
  },
  session: {
    modelName: prefixTableName("betterauth_session"),
  },
  account: {
    modelName: prefixTableName("betterauth_account"),
  },
  verification: {
    modelName: prefixTableName("betterauth_verification"),
  },
  emailAndPassword: {
    enabled: true,
  },
  plugins: [
    openAPI(),
    expo(),
    admin(),
  ],
});

Additional context

No response

Originally created by @jigz on GitHub (Jan 5, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/7127 Originally assigned to: @bytaesu on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Setup Better-Auth 2. Add OpenAPI plugin ### Current vs. Expected behavior Related: https://github.com/better-auth/better-auth/issues/3987 Current: openapi generator is defaulting to string when type is missing resulting in type inconsistency https://github.com/better-auth/better-auth/blob/a4a388d6f5c39cef2507f9e59e8a18bb8f3b549e/packages/better-auth/src/plugins/open-api/generator.ts#L84 https://github.com/better-auth/better-auth/blob/d343b34cf6c0383d0a5833976632462b192dbc1e/packages/better-auth/src/plugins/open-api/__snapshots__/open-api.test.ts.snap#L4003-L4006 https://github.com/better-auth/better-auth/blob/d343b34cf6c0383d0a5833976632462b192dbc1e/packages/better-auth/src/plugins/open-api/__snapshots__/open-api.test.ts.snap#L3407-L3413 <img width="955" height="428" alt="Image" src="https://github.com/user-attachments/assets/5c58c57c-5be6-4a9c-8afb-f2081006e898" /> Expected: - Detect correct type for rememberMe - Remove the dangerous fallback type ### What version of Better Auth are you using? 1.4.10 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 11 Home", "release": "10.0.26200", "cpuCount": 24, "cpuModel": "AMD Ryzen AI 9 HX 370 w/ Radeon 890M ", "totalMemory": "23.62 GB", "freeMemory": "3.85 GB" }, "node": { "version": "v22.14.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.27.0" }, "frameworks": null, "databases": null, "betterAuth": { "version": "Unknown", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { expo } from "@better-auth/expo"; import { betterAuth } from "better-auth"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import { admin, openAPI, } from "better-auth/plugins"; import db from "@/db"; import { prefixTableName } from "@/db/schema"; import packageJson from "./../../package.json" with { type: "json" }; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "pg", }), appName: packageJson.name, user: { modelName: prefixTableName("betterauth_user"), }, session: { modelName: prefixTableName("betterauth_session"), }, account: { modelName: prefixTableName("betterauth_account"), }, verification: { modelName: prefixTableName("betterauth_verification"), }, emailAndPassword: { enabled: true, }, plugins: [ openAPI(), expo(), admin(), ], }); ``` ### Additional context _No response_
GiteaMirror added the lockedenhancement labels 2026-04-15 18:23:10 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Jan 5, 2026):

It looks like you've encountered a known issue about type inconsistency where rememberMe is defined as a string during sign-in but as a boolean during sign-up. There was an open issue reported regarding this, stating that the TypeScript definition for rememberMe is incorrect, even though it works correctly at runtime and accepts boolean values [2].

For next steps, you might consider the following:

  1. Forging a Temporary Workaround: If it’s feasible, you could handle the boolean conversion at your application level until a fix is applied.

  2. Follow the Discussion: Since there has been activity on this issue, keep an eye on its progress for any updates on an official fix or further insights.

  3. Experiment with Updates: Check if updating to any newer versions might resolve this issue as changes or enhancements could have been introduced.

If you have any other questions or need further help, feel free to ask! How are you currently handling this type inconsistency in your application?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3708809668 --> @better-auth-agent[bot] commented on GitHub (Jan 5, 2026): It looks like you've encountered a known issue about type inconsistency where `rememberMe` is defined as a string during sign-in but as a boolean during sign-up. There was an open issue reported regarding this, stating that the TypeScript definition for `rememberMe` is incorrect, even though it works correctly at runtime and accepts boolean values [[2]](https://github.com/better-auth/better-auth/issues/3987). For next steps, you might consider the following: 1. **Forging a Temporary Workaround**: If it’s feasible, you could handle the boolean conversion at your application level until a fix is applied. 2. **Follow the Discussion**: Since there has been activity on this issue, keep an eye on its progress for any updates on an official fix or further insights. 3. **Experiment with Updates**: Check if updating to any newer versions might resolve this issue as changes or enhancements could have been introduced. If you have any other questions or need further help, feel free to ask! How are you currently handling this type inconsistency in your application? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@dosubot[bot] commented on GitHub (Jan 5, 2026):

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

This is a known issue: the OpenAPI plugin in Better-Auth v1.4.10 incorrectly infers the type of rememberMe as string in the sign-in endpoint, while sign-up correctly uses boolean. The root cause is the generator's fallback to string when it can't unwrap the base type from Zod schemas, especially for optional/defaulted fields. This leads to TypeScript errors and runtime validation failures if a string is sent instead of a boolean [source].

A permanent fix for improved type inference and OpenAPI 3.1 compatibility was merged after v1.4.10 in PR #6705, but it's not included in your version. Until you upgrade, the recommended workaround is to manually patch the generated OpenAPI schema after calling auth.api.generateOpenAPISchema() to correct the type for rememberMe [source].

Here’s an example patch for your setup:

const schema = await auth.api.generateOpenAPISchema();
const signInSchema = schema.paths?.["/sign-in/email"]?.post?.requestBody?.content?.["application/json"]?.schema;
if (signInSchema?.properties?.rememberMe) {
  signInSchema.properties.rememberMe.type = "boolean";
  // Optionally, add a description or default value if needed
}
export default schema;

This approach is the best interim solution until you can upgrade to a version with the official fix. Manual schema patching is also used for other OpenAPI generation issues in Better-Auth [source].

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3708813589 --> @dosubot[bot] commented on GitHub (Jan 5, 2026): <!-- Greeting --> Hi @jigz! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a known issue: the OpenAPI plugin in Better-Auth v1.4.10 incorrectly infers the type of `rememberMe` as `string` in the sign-in endpoint, while sign-up correctly uses `boolean`. The root cause is the generator's fallback to `string` when it can't unwrap the base type from Zod schemas, especially for optional/defaulted fields. This leads to TypeScript errors and runtime validation failures if a string is sent instead of a boolean [[source](https://github.com/better-auth/better-auth/issues/3987)]. A permanent fix for improved type inference and OpenAPI 3.1 compatibility was merged after v1.4.10 in [PR #6705](https://github.com/better-auth/better-auth/pull/6705), but it's not included in your version. Until you upgrade, the recommended workaround is to manually patch the generated OpenAPI schema after calling `auth.api.generateOpenAPISchema()` to correct the type for `rememberMe` [[source](https://github.com/better-auth/better-auth/issues/3263#issuecomment-3037413384)]. Here’s an example patch for your setup: ```typescript const schema = await auth.api.generateOpenAPISchema(); const signInSchema = schema.paths?.["/sign-in/email"]?.post?.requestBody?.content?.["application/json"]?.schema; if (signInSchema?.properties?.rememberMe) { signInSchema.properties.rememberMe.type = "boolean"; // Optionally, add a description or default value if needed } export default schema; ``` This approach is the best interim solution until you can upgrade to a version with the official fix. Manual schema patching is also used for other OpenAPI generation issues in Better-Auth [[source](https://github.com/better-auth/better-auth/issues/6250#issuecomment-3568624793)]. <!-- 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/780e835b-da76-41c1-ba9f-43889b31ff35?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/780e835b-da76-41c1-ba9f-43889b31ff35?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/780e835b-da76-41c1-ba9f-43889b31ff35?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/780e835b-da76-41c1-ba9f-43889b31ff35?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/780e835b-da76-41c1-ba9f-43889b31ff35?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/780e835b-da76-41c1-ba9f-43889b31ff35?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/780e835b-da76-41c1-ba9f-43889b31ff35?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20known%20issue%3A%20the%20OpenAPI%20plugin%20in%20Better-Auth%20v1.4.10%20incorrectly%20infers%20the%20type%20of%20%60rememberMe%60%20as%20%60string%60%20in%20the%20sign-in%20endpoint%2C%20while%20sign-up%20correctly%20uses%20%60boolean%60.%20The%20root%20cause%20is%20the%20generator%27s%20fallback%20to%20%60string%60%20when%20it%20can%27t%20unwrap%20the%20base%20type%20from%20Zod%20schemas%2C%20especially%20for%20optional/defaulted%20fields.%20This%20leads%20to%20TypeScript%20errors%20and%20runtime%20validation%20failures%20if%20a%20string%20is%20sent%20instead%20of%20a%20boolean%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/3987%29%5D.%0A%0AA%20permanent%20fix%20for%20improved%20type%20inference%20and%20OpenAPI%203.1%20compatibility%20was%20merged%20after%20v1.4.10%20in%20%5BPR%20%236705%5D%28https%3A//github.com/better-auth/better-auth/pull/6705%29%2C%20but%20it%27s%20not%20included%20in%20your%20version.%20Until%20you%20upgrade%2C%20the%20recommended%20workaround%20is%20to%20manually%20patch%20the%20generated%20OpenAPI%20schema%20after%20calling%20%60auth.api.generateOpenAPISchema%28%29%60%20to%20correct%20the%20type%20for%20%60rememberMe%60%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/3263%23issuecomment-3037413384%29%5D.%0A%0AHere%E2%80%99s%20an%20example%20patch%20for%20your%20setup%3A%0A%0A%60%60%60typescript%0Aconst%20schema%20%3D%20await%20auth.api.generateOpenAPISchema%28%29%3B%0Aconst%20signInSchema%20%3D%20schema.paths%3F.%5B%22/sign-in/email%22%5D%3F.post%3F.requestBody%3F.content%3F.%5B%22application/json%22%5D%3F.schema%3B%0Aif%20%28signInSchema%3F.properties%3F.rememberMe%29%20%7B%0A%20%20signInSchema.properties.rememberMe.type%20%3D%20%22boolean%22%3B%0A%20%20//%20Optionally%2C%20add%20a%20description%20or%20default%20value%20if%20needed%0A%7D%0Aexport%20default%20schema%3B%0A%60%60%60%0A%0AThis%20approach%20is%20the%20best%20interim%20solution%20until%20you%20can%20upgrade%20to%20a%20version%20with%20the%20official%20fix.%20Manual%20schema%20patching%20is%20also%20used%20for%20other%20OpenAPI%20generation%20issues%20in%20Better-Auth%20%5B%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6250%23issuecomment-3568624793%29%5D.)&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/7127)
Author
Owner

@jigz commented on GitHub (Jan 5, 2026):

rememberMe remains undefined and string defaulted in https://github.com/better-auth/better-auth/pull/6705 snap

<!-- gh-comment-id:3708828660 --> @jigz commented on GitHub (Jan 5, 2026): rememberMe remains undefined and string defaulted in https://github.com/better-auth/better-auth/pull/6705 snap
Author
Owner

@dosubot[bot] commented on GitHub (Jan 5, 2026):

PR #6705 does not fix the rememberMe type inconsistency in the OpenAPI schema—it only updates how optional/null types are represented for OpenAPI 3.1 compatibility. The root cause is that the generator can't unwrap ZodDefault, so it falls back to string for sign-in, while sign-up (which uses only .optional()) is correctly typed as boolean. This issue is tracked separately in issue #7127.

Until the generator is improved to handle ZodDefault, the best workaround is to manually patch the generated OpenAPI schema after calling auth.api.generateOpenAPISchema(). For example:

const schema = await auth.api.generateOpenAPISchema();
const signInSchema = schema.paths?.["/sign-in/email"]?.post?.requestBody?.content?.["application/json"]?.schema;
if (signInSchema?.properties?.rememberMe) {
  signInSchema.properties.rememberMe.type = "boolean";
}
export default schema;

Keep an eye on issue #7127 for updates on a permanent fix. Manual patching is the recommended approach for now source.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

<!-- gh-comment-id:3708833516 --> @dosubot[bot] commented on GitHub (Jan 5, 2026): <!-- Answer --> PR #6705 does not fix the rememberMe type inconsistency in the OpenAPI schema—it only updates how optional/null types are represented for OpenAPI 3.1 compatibility. The root cause is that the generator can't unwrap ZodDefault, so it falls back to string for sign-in, while sign-up (which uses only .optional()) is correctly typed as boolean. This issue is tracked separately in [issue #7127](https://github.com/better-auth/better-auth/pull/6705). Until the generator is improved to handle ZodDefault, the best workaround is to manually patch the generated OpenAPI schema after calling `auth.api.generateOpenAPISchema()`. For example: ```typescript const schema = await auth.api.generateOpenAPISchema(); const signInSchema = schema.paths?.["/sign-in/email"]?.post?.requestBody?.content?.["application/json"]?.schema; if (signInSchema?.properties?.rememberMe) { signInSchema.properties.rememberMe.type = "boolean"; } export default schema; ``` Keep an eye on [issue #7127](https://github.com/better-auth/better-auth/pull/6705) for updates on a permanent fix. Manual patching is the recommended approach for now [source](https://github.com/better-auth/better-auth/issues/6250#issuecomment-3568624793). <!-- 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/82c5289b-0e05-4f61-8863-03b08cc0f160?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/82c5289b-0e05-4f61-8863-03b08cc0f160?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/82c5289b-0e05-4f61-8863-03b08cc0f160?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/82c5289b-0e05-4f61-8863-03b08cc0f160?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/82c5289b-0e05-4f61-8863-03b08cc0f160?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/82c5289b-0e05-4f61-8863-03b08cc0f160?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/82c5289b-0e05-4f61-8863-03b08cc0f160?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=PR%20%236705%20does%20not%20fix%20the%20rememberMe%20type%20inconsistency%20in%20the%20OpenAPI%20schema%E2%80%94it%20only%20updates%20how%20optional/null%20types%20are%20represented%20for%20OpenAPI%203.1%20compatibility.%20The%20root%20cause%20is%20that%20the%20generator%20can%27t%20unwrap%20ZodDefault%2C%20so%20it%20falls%20back%20to%20string%20for%20sign-in%2C%20while%20sign-up%20%28which%20uses%20only%20.optional%28%29%29%20is%20correctly%20typed%20as%20boolean.%20This%20issue%20is%20tracked%20separately%20in%20%5Bissue%20%237127%5D%28https%3A//github.com/better-auth/better-auth/pull/6705%29.%0A%0AUntil%20the%20generator%20is%20improved%20to%20handle%20ZodDefault%2C%20the%20best%20workaround%20is%20to%20manually%20patch%20the%20generated%20OpenAPI%20schema%20after%20calling%20%60auth.api.generateOpenAPISchema%28%29%60.%20For%20example%3A%0A%0A%60%60%60typescript%0Aconst%20schema%20%3D%20await%20auth.api.generateOpenAPISchema%28%29%3B%0Aconst%20signInSchema%20%3D%20schema.paths%3F.%5B%22/sign-in/email%22%5D%3F.post%3F.requestBody%3F.content%3F.%5B%22application/json%22%5D%3F.schema%3B%0Aif%20%28signInSchema%3F.properties%3F.rememberMe%29%20%7B%0A%20%20signInSchema.properties.rememberMe.type%20%3D%20%22boolean%22%3B%0A%7D%0Aexport%20default%20schema%3B%0A%60%60%60%0A%0AKeep%20an%20eye%20on%20%5Bissue%20%237127%5D%28https%3A//github.com/better-auth/better-auth/pull/6705%29%20for%20updates%20on%20a%20permanent%20fix.%20Manual%20patching%20is%20the%20recommended%20approach%20for%20now%20%5Bsource%5D%28https%3A//github.com/better-auth/better-auth/issues/6250%23issuecomment-3568624793%29.)&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/7127)
Author
Owner

@bytaesu commented on GitHub (Jan 7, 2026):

Hi @jigz,

I'm checking this 🙂

<!-- gh-comment-id:3718561813 --> @bytaesu commented on GitHub (Jan 7, 2026): Hi @jigz, I'm checking this 🙂
Author
Owner

@bytaesu commented on GitHub (Jan 7, 2026):

Thanks @jigz, Nice catch!
Will be resolved soon 🙏

<!-- gh-comment-id:3718723812 --> @bytaesu commented on GitHub (Jan 7, 2026): Thanks @jigz, Nice catch! Will be resolved soon 🙏
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19368