Cannot call listTeamMembers as Organization owner when not part of a team #2969

Closed
opened 2026-03-13 10:31:14 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @DarkNasuada on GitHub (Mar 3, 2026).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Call auth.api.listTeamMembers({
						headers: requestHeaders,
						query: {
							teamId: teamId,
						},
					})

while being an organization owner

Current vs. Expected behavior

when calling

auth.api.listTeamMembers({
						headers: requestHeaders,
						query: {
							teamId: teamId,
						},
					})

i get the following error:

Error fetching members for team JxV9e6BNpZ9W6x7aEJHUfHqQ3VwVClCf: [Error [APIError]: User is not a member of the team] {
  status: 'BAD_REQUEST',
  body: [Object],
  headers: {},
  statusCode: 400
}

i expect to be able to call all endpoints of the organization api when being the organization owner.

What version of Better Auth are you using?

1.5.1

System info

{
  "system": {
    "platform": "win32",
    "arch": "x64",
    "version": "Windows 11 Pro",
    "release": "10.0.26100",
    "cpuCount": 28,
    "cpuModel": "Intel(R) Core(TM) i7-14700",
    "totalMemory": "31.68 GB",
    "freeMemory": "8.77 GB"
  },
  "node": {
    "version": "v25.6.1",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "11.9.0"
  },
  "frameworks": [
    {
      "name": "next",
      "version": "^16.1.6"
    },
    {
      "name": "react",
      "version": "^19.2.4"
    }
  ],
  "databases": null,
  "betterAuth": {
    "version": "^1.5.1",
    "config": null
  }
}

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

Backend

Auth config (if applicable)


Additional context

No response

Originally created by @DarkNasuada on GitHub (Mar 3, 2026). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce ``` Call auth.api.listTeamMembers({ headers: requestHeaders, query: { teamId: teamId, }, }) ``` while being an organization owner ### Current vs. Expected behavior when calling ``` auth.api.listTeamMembers({ headers: requestHeaders, query: { teamId: teamId, }, }) ``` i get the following error: ``` Error fetching members for team JxV9e6BNpZ9W6x7aEJHUfHqQ3VwVClCf: [Error [APIError]: User is not a member of the team] { status: 'BAD_REQUEST', body: [Object], headers: {}, statusCode: 400 } ``` i expect to be able to call all endpoints of the organization api when being the organization owner. ### What version of Better Auth are you using? 1.5.1 ### System info ```bash { "system": { "platform": "win32", "arch": "x64", "version": "Windows 11 Pro", "release": "10.0.26100", "cpuCount": 28, "cpuModel": "Intel(R) Core(TM) i7-14700", "totalMemory": "31.68 GB", "freeMemory": "8.77 GB" }, "node": { "version": "v25.6.1", "env": "development" }, "packageManager": { "name": "npm", "version": "11.9.0" }, "frameworks": [ { "name": "next", "version": "^16.1.6" }, { "name": "react", "version": "^19.2.4" } ], "databases": null, "betterAuth": { "version": "^1.5.1", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript ``` ### Additional context _No response_
Author
Owner

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

This is expected behavior by design, not a bug. The listTeamMembers function strictly enforces team membership verification and does not check organization-level roles.

From the related issue #3693, the rationale is security and RBAC best practices—keeping permissions explicit prevents privilege creep and accidental data exposure.

Workarounds:

  1. Add organization owners as explicit team members programmatically
  2. Use the organization-level listMembers API to get all org members instead
  3. Modify the listTeamMembers endpoint code to check org-level roles

The maintainers have indicated an opt-in flag for this could be added in the future, but it's not currently configurable.

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

@dosubot[bot] commented on GitHub (Mar 3, 2026): <!-- Answer --> This is **expected behavior by design**, not a bug. The [`listTeamMembers` function](https://github.com/better-auth/better-auth/blob/35deabdef026f6887eb5dfda539f39460076fad4/packages/better-auth/src/plugins/organization/routes/crud-team.ts#L825-L904) strictly enforces team membership verification and does not check organization-level roles. From the [related issue #3693](https://github.com/better-auth/better-auth/issues/3693#issuecomment-3134097806), the rationale is security and RBAC best practices—keeping permissions explicit prevents privilege creep and accidental data exposure. **Workarounds:** 1. Add organization owners as explicit team members programmatically 2. Use the organization-level `listMembers` API to get all org members instead 3. Modify the `listTeamMembers` endpoint code to check org-level roles The maintainers have indicated an opt-in flag for this could be added in the future, but it's not currently configurable. <!-- 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/9524d342-dc5a-4ed1-b9a7-d70c88ee8417?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/9524d342-dc5a-4ed1-b9a7-d70c88ee8417?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/9524d342-dc5a-4ed1-b9a7-d70c88ee8417?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/9524d342-dc5a-4ed1-b9a7-d70c88ee8417?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/9524d342-dc5a-4ed1-b9a7-d70c88ee8417?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/9524d342-dc5a-4ed1-b9a7-d70c88ee8417?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/9524d342-dc5a-4ed1-b9a7-d70c88ee8417?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%20%2A%2Aexpected%20behavior%20by%20design%2A%2A%2C%20not%20a%20bug.%20The%20%5B%60listTeamMembers%60%20function%5D%28https%3A//github.com/better-auth/better-auth/blob/35deabdef026f6887eb5dfda539f39460076fad4/packages/better-auth/src/plugins/organization/routes/crud-team.ts%23L825-L904%29%20strictly%20enforces%20team%20membership%20verification%20and%20does%20not%20check%20organization-level%20roles.%0A%0AFrom%20the%20%5Brelated%20issue%20%233693%5D%28https%3A//github.com/better-auth/better-auth/issues/3693%23issuecomment-3134097806%29%2C%20the%20rationale%20is%20security%20and%20RBAC%20best%20practices%E2%80%94keeping%20permissions%20explicit%20prevents%20privilege%20creep%20and%20accidental%20data%20exposure.%0A%0A%2A%2AWorkarounds%3A%2A%2A%0A1.%20Add%20organization%20owners%20as%20explicit%20team%20members%20programmatically%0A2.%20Use%20the%20organization-level%20%60listMembers%60%20API%20to%20get%20all%20org%20members%20instead%0A3.%20Modify%20the%20%60listTeamMembers%60%20endpoint%20code%20to%20check%20org-level%20roles%0A%0AThe%20maintainers%20have%20indicated%20an%20opt-in%20flag%20for%20this%20could%20be%20added%20in%20the%20future%2C%20but%20it%27s%20not%20currently%20configurable.)&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/8329)
Author
Owner

@DarkNasuada commented on GitHub (Mar 3, 2026):

@dosu according to the docs:

owner: The user who created the organization by default. The owner has full control over the organization and can perform any action.

So an organization owner cannot perform any action?

@DarkNasuada commented on GitHub (Mar 3, 2026): @dosu according to the docs: owner: The user who created the organization by default. The owner has full control over the organization and can perform any action. So an organization owner cannot perform any action?
Author
Owner

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

You raise a valid point! The documentation does say owners can "perform any action," but there's a gap between what the docs claim and what the code actually does.

Looking at the implementation, owners have a defined set of permissions for organization-level actions (like update/delete org, manage members, create/update/delete teams, etc.), but listTeamMembers specifically checks team membership rather than organization role.

So you're right—the docs are misleading here. "Full control" applies to organization-level operations, but some team-level read operations like listTeamMembers require explicit team membership regardless of org role. This could reasonably be considered either a documentation bug or a missing feature.

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

@dosubot[bot] commented on GitHub (Mar 3, 2026): <!-- Answer --> You raise a valid point! The [documentation](https://better-auth.com/docs/plugins/organization) does say owners can "perform any action," but there's a gap between what the docs claim and what the code actually does. Looking at the implementation, owners have a [defined set of permissions](https://github.com/better-auth/better-auth/blob/35deabdef026f6887eb5dfda539f39460076fad4/packages/better-auth/src/plugins/organization/access/statement.ts#L13-L27) for organization-level actions (like update/delete org, manage members, create/update/delete teams, etc.), but [`listTeamMembers` specifically checks team membership](https://github.com/better-auth/better-auth/blob/35deabdef026f6887eb5dfda539f39460076fad4/packages/better-auth/src/plugins/organization/routes/crud-team.ts#L825-L904) rather than organization role. So you're right—the docs are misleading here. "Full control" applies to organization-level operations, but some team-level read operations like `listTeamMembers` require explicit team membership regardless of org role. This could reasonably be considered either a documentation bug or a missing feature. <!-- 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/f3f637c4-572c-4781-82e5-84642916c8ea?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/f3f637c4-572c-4781-82e5-84642916c8ea?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/f3f637c4-572c-4781-82e5-84642916c8ea?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/f3f637c4-572c-4781-82e5-84642916c8ea?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/f3f637c4-572c-4781-82e5-84642916c8ea?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/f3f637c4-572c-4781-82e5-84642916c8ea?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/f3f637c4-572c-4781-82e5-84642916c8ea?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=You%20raise%20a%20valid%20point%21%20The%20%5Bdocumentation%5D%28https%3A//better-auth.com/docs/plugins/organization%29%20does%20say%20owners%20can%20%22perform%20any%20action%2C%22%20but%20there%27s%20a%20gap%20between%20what%20the%20docs%20claim%20and%20what%20the%20code%20actually%20does.%0A%0ALooking%20at%20the%20implementation%2C%20owners%20have%20a%20%5Bdefined%20set%20of%20permissions%5D%28https%3A//github.com/better-auth/better-auth/blob/35deabdef026f6887eb5dfda539f39460076fad4/packages/better-auth/src/plugins/organization/access/statement.ts%23L13-L27%29%20for%20organization-level%20actions%20%28like%20update/delete%20org%2C%20manage%20members%2C%20create/update/delete%20teams%2C%20etc.%29%2C%20but%20%5B%60listTeamMembers%60%20specifically%20checks%20team%20membership%5D%28https%3A//github.com/better-auth/better-auth/blob/35deabdef026f6887eb5dfda539f39460076fad4/packages/better-auth/src/plugins/organization/routes/crud-team.ts%23L825-L904%29%20rather%20than%20organization%20role.%0A%0ASo%20you%27re%20right%E2%80%94the%20docs%20are%20misleading%20here.%20%22Full%20control%22%20applies%20to%20organization-level%20operations%2C%20but%20some%20team-level%20read%20operations%20like%20%60listTeamMembers%60%20require%20explicit%20team%20membership%20regardless%20of%20org%20role.%20This%20could%20reasonably%20be%20considered%20either%20a%20documentation%20bug%20or%20a%20missing%20feature.)&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/8329)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2969