[GH-ISSUE #9156] dash plugin insight incorrectly flags custom defaultRole as non-existent #19923

Closed
opened 2026-04-15 19:17:45 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @gatezh on GitHub (Apr 13, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/9156

Is this suited for github?

  • Yes, this is suited for github

Reproduction

  1. Configure the admin plugin with a custom defaultRole and matching custom roles:
admin({
  ac: defaultAc as AccessControl,
  defaultRole: "agent",
  roles: {
    customer: userAc,
    agent: userAc,
    admin: adminAc,
  },
})
  1. Configure the dash plugin from @better-auth/infra:
dash({ apiKey: env.BETTER_AUTH_API_KEY })
  1. Open the Better Auth Infrastructure dashboard
  2. Observe the insight/warning:

    The default role "agent" assigned to new users does not exist in the defined roles.

Current vs. Expected behavior

Current: The dashboard flags defaultRole: "agent" as not existing in the defined roles.

Expected: The dashboard should recognize "agent" as a valid role since it exists as a key in the custom roles map passed to the admin plugin. The server-side admin plugin itself does not raise any error — the role is correctly applied to new users at runtime.

One theory is that the insight checks defaultRole against the built-in defaultRoles (admin + user) rather than the custom roles object. The /dash/config endpoint does serialize the plugin options (including both defaultRole and the roles keys) via sanitizePluginOptions(), so the data needed for correct validation appears to be available — but since the dash plugin source is not public, we can't confirm where the check happens.

What version of Better Auth are you using?

1.6.2

System info

- `@better-auth/infra`: 0.2.0
- Runtime: Cloudflare Workers (Hono)
- Database: Cloudflare D1 (SQLite)

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

Client, Backend

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { admin } from "better-auth/plugins";
import { dash, sentinel } from "@better-auth/infra";
import { adminAc, defaultAc, userAc } from "better-auth/plugins/admin/access";
import type { AccessControl } from "better-auth/plugins/access";

export const auth = betterAuth({
  // ...
  plugins: [
    admin({
      ac: defaultAc as AccessControl,
      defaultRole: "agent",
      roles: {
        customer: userAc,
        agent: userAc,
        admin: adminAc,
      },
    }),
    dash({
      apiKey: env.BETTER_AUTH_API_KEY,
    }),
    sentinel({
      apiKey: env.BETTER_AUTH_API_KEY,
    }),
  ],
});

Additional context

Related issues:

  • #2128 — fix for defaultRole/adminRoles not applying user config
  • #6991 / #6997 — fix for custom role type inference
  • #6081 / #6097hasPermission silent false for unknown roles
Originally created by @gatezh on GitHub (Apr 13, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/9156 ### Is this suited for github? - [x] Yes, this is suited for github ### Reproduction 1. Configure the admin plugin with a custom `defaultRole` and matching custom `roles`: ```ts admin({ ac: defaultAc as AccessControl, defaultRole: "agent", roles: { customer: userAc, agent: userAc, admin: adminAc, }, }) ``` 2. Configure the `dash` plugin from `@better-auth/infra`: ```ts dash({ apiKey: env.BETTER_AUTH_API_KEY }) ``` 3. Open the Better Auth Infrastructure dashboard 4. Observe the insight/warning: > The default role "agent" assigned to new users does not exist in the defined roles. ### Current vs. Expected behavior **Current:** The dashboard flags `defaultRole: "agent"` as not existing in the defined roles. **Expected:** The dashboard should recognize `"agent"` as a valid role since it exists as a key in the custom `roles` map passed to the admin plugin. The server-side admin plugin itself does not raise any error — the role is correctly applied to new users at runtime. One theory is that the insight checks `defaultRole` against the built-in `defaultRoles` (`admin` + `user`) rather than the custom `roles` object. The `/dash/config` endpoint does serialize the plugin options (including both `defaultRole` and the `roles` keys) via `sanitizePluginOptions()`, so the data needed for correct validation appears to be available — but since the `dash` plugin source is not public, we can't confirm where the check happens. ### What version of Better Auth are you using? 1.6.2 ### System info ```bash - `@better-auth/infra`: 0.2.0 - Runtime: Cloudflare Workers (Hono) - Database: Cloudflare D1 (SQLite) ``` ### Which area(s) are affected? (Select all that apply) Client, Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { admin } from "better-auth/plugins"; import { dash, sentinel } from "@better-auth/infra"; import { adminAc, defaultAc, userAc } from "better-auth/plugins/admin/access"; import type { AccessControl } from "better-auth/plugins/access"; export const auth = betterAuth({ // ... plugins: [ admin({ ac: defaultAc as AccessControl, defaultRole: "agent", roles: { customer: userAc, agent: userAc, admin: adminAc, }, }), dash({ apiKey: env.BETTER_AUTH_API_KEY, }), sentinel({ apiKey: env.BETTER_AUTH_API_KEY, }), ], }); ``` ### Additional context Related issues: - #2128 — fix for `defaultRole`/`adminRoles` not applying user config - #6991 / #6997 — fix for custom role type inference - #6081 / #6097 — `hasPermission` silent false for unknown roles
GiteaMirror added the devtools label 2026-04-15 19:17:45 -05:00
Author
Owner

@jonathansamines commented on GitHub (Apr 13, 2026):

Hey @gatezh, we just released @better-auth/infra 0.2.2 with a fix for this. This was a serialization bug on our side. Please let us know how the new version works for you 🙏🏻 .

<!-- gh-comment-id:4239953967 --> @jonathansamines commented on GitHub (Apr 13, 2026): Hey @gatezh, we just released `@better-auth/infra` 0.2.2 with a fix for this. This was a serialization bug on our side. Please let us know how the new version works for you 🙏🏻 .
Author
Owner

@gatezh commented on GitHub (Apr 15, 2026):

Thanks a lot @jonathansamines – confirmed the fix, no warnings anymore

<!-- gh-comment-id:4254783265 --> @gatezh commented on GitHub (Apr 15, 2026): Thanks a lot @jonathansamines – confirmed the fix, no warnings anymore
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#19923