Repository navigation
Fall back to an existing principal when no personal bench slug matches on connect - #685
Merged
TheGreatAxios merged 6 commits intoSep 8, 2026
Conversation
A seeded admin's only membership is the root bench, whose slug never equals the computed personal-bench slug, so a connect used to 409. Cover the seeded-admin shape, the zero-principal shape, the slug-match happy path, and the first-in-page-order pick rule.
findPersonalTenant hard-failed when no principal carried the computed personal-bench slug, 409ing a seeded admin whose only membership is the root bench. An exact slug match still wins; absent one, the first principal in the same /api/me/principals read is used, and only a zero-principal response yields no-personal-bench.
findPersonalTenant's tests pin the strict match as the default (the boot seeder keeps throwing until the root bench is visible) with the fallback opt-in via flag, and the pick rule asserts the full resolved tenant. Route-level tests cover both connect surfaces for a root-bench-only admin: POST /complete persists the credential instead of 409, and POST /complete-setup reports unseeded instead of 409.
The fallback no longer fires for the boot seeder's org-slug lookup, which must keep waiting for the root bench instead of seeding onto the first visible principal. findPersonalTenant is strict by default; only the connect flow (testAndPersistCredential and the /complete-setup route) passes fallbackToFirstPrincipal.
A seeded admin whose browser double-fires the OAuth callback recovers as connected rather than state_expired: a route-level test pins the duplicate-callback recovery for a root-bench-only admin. The findPersonalTenant principals stub drops an inert tenantDomain field; that read only ever comes from GET /api/tenants/:id.
recentlyConnectedCredential resolves through the fallback like the rest of the connect flow, so a seeded admin (root bench only) whose second callback arrival burns the state still recovers the connection that succeeded. The caller enumeration on findPersonalTenant names it.
Contributor
Author
|
Self-review ( |
TheGreatAxios
deleted the
cl-7506-fall-back-to-an-existing-principal-when-no-personal-bench
branch
September 9, 2026 04:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Verification
bun run checkexits 0 (typecheck, lint, full test matrix, structural checks) before each commit; the push-time pre-push gate ran the full suite green (935 pass / 0 fail on the final web shard).bun test packages/onboardingexits 0: 195 pass, 0 fail across 15 files.Closes CL-7506