Found while documenting POST /organization/add-member for #10050. Not ridden into that PR — it is a source-comment defect in two other packages, and the docs PR is content/docs only.
The claim
packages/platform-objects/src/identity/sys-member.object.ts (the add_member action):
// organizationId/teamId default to the caller's active org/team when// omitted, so we leave them as optional params.
The same sentence is repeated, as the authority for the mount's behaviour, in:
packages/plugins/plugin-auth/src/organization-add-member.ts — module header, organizationId default section: "the behaviour the sys_member action metadata documents ("organizationId/teamId default to the caller's active org/team when omitted")"packages/plugins/plugin-auth/src/auth-plugin.ts — the comment above the mount cites the same action metadata.
What the vendor actually does
Measured on the installed better-auth 1.7.1, dist/plugins/organization/routes/crud-members.mjs, inside addMember's handler:
constorgId=ctx.body.organizationId||session?.session.activeOrganizationId;if(!orgId)throwAPIError.from("BAD_REQUEST",ORGANIZATION_ERROR_CODES.NO_ACTIVE_ORGANIZATION);constteamId="teamId"inctx.body ? ctx.body.teamId : void0;The organizationId half is correct — it falls back to session.activeOrganizationId, which is why the mount forwards request headers and why the omitted-org case yields 400 NO_ACTIVE_ORGANIZATION.
The teamId half is wrong. There is no activeTeamId fallback anywhere in that handler: an omitted teamId stays undefined, and the member is created with no team association at all. Nothing later in the handler re-resolves it — the if (teamId) branches (team lookup, TEAM_NOT_FOUND, maximumMembersPerTeam) are all simply skipped.
Why it is worth fixing rather than shrugging at
The sentence is not decoration — it is cited by the mount as the justification for forwarding headers, so the next author reading organization-add-member.ts inherits a false premise about what header forwarding buys. It also reads as a promise the action deliberately declines to make: the add_member action's params list does not include teamId at all, so the toolbar never sends it and the claim has never been exercised.
No behaviour is wrong today — this is a wrong citation, not a bug. The teamId forwarding itself is correct (pass it and it works; omit it and you get no team, which is what the code does).
Suggested fix
Correct the sentence in all three sites to say that organizationId falls back to the caller's active organization and teamId has no fallback. Worth a pin: the docs written for #10050 now state the asymmetry, so a future vendor bump that adds an active-team fallback would put docs and vendor out of sync with nothing watching.
Refs
#10050 (the docs card this surfaced under) · #9941 / PR #10049 (the mount) · better-auth 1.7.1
Found while documenting
POST /organization/add-memberfor #10050. Not ridden into that PR — it is a source-comment defect in two other packages, and the docs PR iscontent/docsonly.The claim
packages/platform-objects/src/identity/sys-member.object.ts(theadd_memberaction):The same sentence is repeated, as the authority for the mount's behaviour, in:
packages/plugins/plugin-auth/src/organization-add-member.ts— module header,organizationId defaultsection: "the behaviour thesys_memberaction metadata documents ("organizationId/teamId default to the caller's active org/team when omitted")"packages/plugins/plugin-auth/src/auth-plugin.ts— the comment above the mount cites the same action metadata.What the vendor actually does
Measured on the installed better-auth 1.7.1,
dist/plugins/organization/routes/crud-members.mjs, insideaddMember's handler:The
organizationIdhalf is correct — it falls back tosession.activeOrganizationId, which is why the mount forwards request headers and why the omitted-org case yields400 NO_ACTIVE_ORGANIZATION.The
teamIdhalf is wrong. There is noactiveTeamIdfallback anywhere in that handler: an omittedteamIdstaysundefined, and the member is created with no team association at all. Nothing later in the handler re-resolves it — theif (teamId)branches (team lookup,TEAM_NOT_FOUND,maximumMembersPerTeam) are all simply skipped.Why it is worth fixing rather than shrugging at
The sentence is not decoration — it is cited by the mount as the justification for forwarding headers, so the next author reading
organization-add-member.tsinherits a false premise about what header forwarding buys. It also reads as a promise the action deliberately declines to make: theadd_memberaction'sparamslist does not includeteamIdat all, so the toolbar never sends it and the claim has never been exercised.No behaviour is wrong today — this is a wrong citation, not a bug. The
teamIdforwarding itself is correct (pass it and it works; omit it and you get no team, which is what the code does).Suggested fix
Correct the sentence in all three sites to say that
organizationIdfalls back to the caller's active organization andteamIdhas no fallback. Worth a pin: the docs written for #10050 now state the asymmetry, so a future vendor bump that adds an active-team fallback would put docs and vendor out of sync with nothing watching.Refs
#10050 (the docs card this surfaced under) · #9941 / PR #10049 (the mount) · better-auth 1.7.1