[GH-ISSUE #8604] useActiveMemberRole does not return owner role, although saved in db row. #28456

Open
opened 2026-04-17 19:54:07 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @Shakil-Ahmmed-Dev on GitHub (Mar 14, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8604

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Fork this repo
  2. Open index.tsx (/src/index.tsx)
  3. You will see the type error:
    This comparison appears to be unintentional because the types '"member" | "admin"' and '"owner"' have no overlap.

Current vs. Expected behavior

Current error:
This comparison appears to be unintentional because the types '"member" | "admin"' and '"owner"' have no overlap.

Expected no errors, owner should be a default role of an organization.

What version of Better Auth are you using?

1.5.3

System info

Tech Stack:
Tanstack Start
Better Auth
Drizzle ORM
SQLite (Used in the repo, PostgreSQL was used in the original problem source)

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

Types

Auth config (if applicable)

import { db } from '#/db'
import { betterAuth } from 'better-auth'
import { tanstackStartCookies } from 'better-auth/tanstack-start'
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
import { organization } from "better-auth/plugins/organization";
import { ac, roles } from './permissions';

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

Additional context

As it is a type error, I guess it will be visible only in the IDE

Originally created by @Shakil-Ahmmed-Dev on GitHub (Mar 14, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8604 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Fork [this repo](https://github.com/Shakil-Ahmmed-Dev/better-auth-role-type-issue) 2. Open index.tsx (/src/index.tsx) 3. You will see the type error: This comparison appears to be unintentional because the types '"member" | "admin"' and '"owner"' have no overlap. ### Current vs. Expected behavior Current error: This comparison appears to be unintentional because the types '"member" | "admin"' and '"owner"' have no overlap. Expected no errors, `owner` should be a default role of an organization. ### What version of Better Auth are you using? 1.5.3 ### System info ```bash Tech Stack: Tanstack Start Better Auth Drizzle ORM SQLite (Used in the repo, PostgreSQL was used in the original problem source) ``` ### Which area(s) are affected? (Select all that apply) Types ### Auth config (if applicable) ```typescript import { db } from '#/db' import { betterAuth } from 'better-auth' import { tanstackStartCookies } from 'better-auth/tanstack-start' import { drizzleAdapter } from 'better-auth/adapters/drizzle' import { organization } from "better-auth/plugins/organization"; import { ac, roles } from './permissions'; export const auth = betterAuth({ database: drizzleAdapter(db, { provider: "sqlite" }), emailAndPassword: { enabled: true, }, plugins: [ organization({ ac, roles }), tanstackStartCookies() ], }); ``` ### Additional context As it is a type error, I guess it will be visible only in the IDE
GiteaMirror added the bugorganization labels 2026-04-17 19:54:07 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 14, 2026):

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

This is a known type inference issue in Better Auth. The role type returned by useActiveMemberRole isn't properly including "owner" (and potentially other custom roles) due to a regression introduced in v1.4.6+ where custom roles are no longer properly inferred in plugin API types.

The default organization roles (owner, admin, member) should all be included in the type, but the type helper is falling back to hardcoded defaults instead of inferring from configuration.

Workarounds:

  1. Install the patched version (recommended):

    npm i https://pkg.pr.new/better-auth/better-auth@e9d54fa
    

    Then clear your TypeScript cache.

  2. Downgrade to v1.4.5 if the patch doesn't work for your use case.

  3. Use a type assertion as a temporary fix (not ideal but works):

    if ((role as string) === "owner") { ... }
    

This issue is related to #2285 and #6991 which track similar type mismatches.

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:4060014430 --> @dosubot[bot] commented on GitHub (Mar 14, 2026): <!-- Greeting --> Hi @Shakil-Ahmmed-Dev! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a **known type inference issue** in Better Auth. The role type returned by `useActiveMemberRole` isn't properly including "owner" (and potentially other custom roles) due to a [regression introduced in v1.4.6+](https://github.com/better-auth/better-auth/issues/6991#issuecomment-3690346537) where custom roles are no longer properly inferred in plugin API types. The [default organization roles](https://github.com/better-auth/better-auth/blob/64339f06459b0ff940cae8bbda705371c216de39/packages/better-auth/src/plugins/organization/access/statement.ts#L37-L41) (owner, admin, member) should all be included in the type, but the type helper is falling back to hardcoded defaults instead of inferring from configuration. **Workarounds:** 1. **Install the patched version** (recommended): ```bash npm i https://pkg.pr.new/better-auth/better-auth@e9d54fa ``` Then clear your TypeScript cache. 2. **Downgrade to v1.4.5** if the patch doesn't work for your use case. 3. **Use a type assertion** as a temporary fix (not ideal but works): ```typescript if ((role as string) === "owner") { ... } ``` This issue is related to [#2285](https://github.com/better-auth/better-auth/issues/2285) and [#6991](https://github.com/better-auth/better-auth/issues/6991) which track similar type mismatches. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=brand-link).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/a2e1806b-2a28-434c-9718-a6b56d15c855?feedback_type=great_response&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/a2e1806b-2a28-434c-9718-a6b56d15c855?feedback_type=irrelevant_answer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/a2e1806b-2a28-434c-9718-a6b56d15c855?feedback_type=incorrect_sources&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/a2e1806b-2a28-434c-9718-a6b56d15c855?feedback_type=too_verbose&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/a2e1806b-2a28-434c-9718-a6b56d15c855?feedback_type=hallucination&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/a2e1806b-2a28-434c-9718-a6b56d15c855?feedback_type=bug_report&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-bug_report) | [Other](https://app.dosu.dev/response-feedback/a2e1806b-2a28-434c-9718-a6b56d15c855?feedback_type=other&utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=feedback-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&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=chat-badge)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=This%20is%20a%20%2A%2Aknown%20type%20inference%20issue%2A%2A%20in%20Better%20Auth.%20The%20role%20type%20returned%20by%20%60useActiveMemberRole%60%20isn%27t%20properly%20including%20%22owner%22%20%28and%20potentially%20other%20custom%20roles%29%20due%20to%20a%20%5Bregression%20introduced%20in%20v1.4.6%2B%5D%28https%3A//github.com/better-auth/better-auth/issues/6991%23issuecomment-3690346537%29%20where%20custom%20roles%20are%20no%20longer%20properly%20inferred%20in%20plugin%20API%20types.%0A%0AThe%20%5Bdefault%20organization%20roles%5D%28https%3A//github.com/better-auth/better-auth/blob/64339f06459b0ff940cae8bbda705371c216de39/packages/better-auth/src/plugins/organization/access/statement.ts%23L37-L41%29%20%28owner%2C%20admin%2C%20member%29%20should%20all%20be%20included%20in%20the%20type%2C%20but%20the%20type%20helper%20is%20falling%20back%20to%20hardcoded%20defaults%20instead%20of%20inferring%20from%20configuration.%0A%0A%2A%2AWorkarounds%3A%2A%2A%0A%0A1.%20%2A%2AInstall%20the%20patched%20version%2A%2A%20%28recommended%29%3A%0A%20%20%20%60%60%60bash%0A%20%20%20npm%20i%20https%3A//pkg.pr.new/better-auth/better-auth%40e9d54fa%0A%20%20%20%60%60%60%0A%20%20%20Then%20clear%20your%20TypeScript%20cache.%0A%0A2.%20%2A%2ADowngrade%20to%20v1.4.5%2A%2A%20if%20the%20patch%20doesn%27t%20work%20for%20your%20use%20case.%0A%0A3.%20%2A%2AUse%20a%20type%20assertion%2A%2A%20as%20a%20temporary%20fix%20%28not%20ideal%20but%20works%29%3A%0A%20%20%20%60%60%60typescript%0A%20%20%20if%20%28%28role%20as%20string%29%20%3D%3D%3D%20%22owner%22%29%20%7B%20...%20%7D%0A%20%20%20%60%60%60%0A%0AThis%20issue%20is%20related%20to%20%5B%232285%5D%28https%3A//github.com/better-auth/better-auth/issues/2285%29%20and%20%5B%236991%5D%28https%3A//github.com/better-auth/better-auth/issues/6991%29%20which%20track%20similar%20type%20mismatches.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-assistant&utm_content=join-discord)&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/8604)
Author
Owner

@KushalXCoder commented on GitHub (Mar 15, 2026):

I would like to solve the type error raised in this issue. So, should I wait for assignment or fix it and create a PR ?

<!-- gh-comment-id:4062307662 --> @KushalXCoder commented on GitHub (Mar 15, 2026): I would like to solve the type error raised in this issue. So, should I wait for assignment or fix it and create a PR ?
Author
Owner

@Shakil-Ahmmed-Dev commented on GitHub (Mar 15, 2026):

If possible, fixing and creating a PR should be a better option.

<!-- gh-comment-id:4062310145 --> @Shakil-Ahmmed-Dev commented on GitHub (Mar 15, 2026): If possible, fixing and creating a PR should be a better option.
Author
Owner

@KushalXCoder commented on GitHub (Mar 15, 2026):

Ok, would do that.

<!-- gh-comment-id:4062318843 --> @KushalXCoder commented on GitHub (Mar 15, 2026): Ok, would do that.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#28456