Found by the independent review of PR #21813 (#21791). Low; predates 17.6.0, but #21813 makes it reachable (a recorded owner bind recreates a deleted default organization).
Mechanism
packages/plugins/plugin-auth/src/tenancy-service.ts (~L490) memoizes cachedDefaultOrgId for the life of the process. If the default organization is deleted and recreated in the same process, users created under the auto membership policy afterwards are bound to the deleted organization's id; since membership is now decided once at creation, nothing repairs it later.
Done when
The cached id is revalidated (or cleared on a sys_organization delete/insert), and a test deletes and recreates the default organization and creates a user in the same process.
Generated by Claude Code
Found by the independent review of PR #21813 (#21791). Low; predates 17.6.0, but #21813 makes it reachable (a recorded owner bind recreates a deleted default organization).
Mechanism
packages/plugins/plugin-auth/src/tenancy-service.ts(~L490) memoizescachedDefaultOrgIdfor the life of the process. If the default organization is deleted and recreated in the same process, users created under theautomembership policy afterwards are bound to the deleted organization's id; since membership is now decided once at creation, nothing repairs it later.Done when
The cached id is revalidated (or cleared on a
sys_organizationdelete/insert), and a test deletes and recreates the default organization and creates a user in the same process.Generated by Claude Code