Skip to content

bug(platform): a failed organization switch is recorded as done and leaves an endless "Switching organization…" spinner #4887

Closed

Description

@yannickmonney

Problem

Switching organizations, from the account menu's organization list or a /dashboard/switching link, never checks whether the switch succeeded. A refused or failed switch leaves the person on an endless "Switching organization…" spinner, and is recorded in the audit log as if it happened. The switcher also shows raw role ids and goes silently empty when its list can't load. Paths at main c94f1fd84, under services/platform/.

  1. A failed setActive is treated as success.
    • app/routes/dashboard/switching.tsx:77-79 awaits authClient.organization.setActive(…) and never reads its result.
    • The Better Auth client reports a failed request as { data: null, error } without throwing. The codebase says so itself (app/features/organization/components/onboarding/steps/workspace-step.tsx:146-147), and lib/auth-client.ts:59-67 configures retries but no throw.
    • The route then records the switch in the audit log (recordOrgSwitch, :84-86) and navigates to the target organization (:143-155). The catch (:129-131) only covers thrown errors.
  2. The dashboard then waits forever.
    • app/routes/dashboard/$id.tsx:160-182 retries the switch once (orgSyncRef), ignores that result too and records the switch again (:169-173). orgSyncRef is only reset in its catch, so a returned error is never retried.
    • While the session's active organization differs from the URL, isSwitching (:232-236) renders only a spinner with "Switching organization…" (:384-395). There's no error, no timeout and no way back except a manual reload.
    • Triggers include a refusal such as a 429, a 5xx that outlasts the client's 4 retries, or a dropped connection.
  3. Raw role ids. The switcher's second line is {org.slug ? \@${org.slug} · ` : ''}{org.role} (app/features/organization/components/organization-list-panel.tsx:97-100). Every user sees "@acme · owner" or "member" in English lowercase, in every locale. The localized names exist (useRoleLabel, app/features/settings/organization/components/role-badge.tsx:12; messages/de/roles.yml`: owner → "Inhaber"), and that catalog says these are the role names "everywhere (… the account menu …)".
  4. Empty switcher on a failed list read. organization-list-panel.tsx:35 and :59 (const orgs = userOrgs ?? []): when /organizations fails, the switcher opens empty, apart from Create organization. A member of several organizations can't switch and isn't told why.

Expected

  • Check setActive's error in both places, or pass fetchOptions: { throw: true }. On failure, stay on, or return to, the current organization and say "Couldn't switch to {name}" with Try again. Don't record the switch.
  • Bound the isSwitching state: after a failed or timed-out sync, show an error with Try again and a link back.
  • Render roles through useRoleLabel. Show a list read error, with Try again, instead of an empty switcher.

Regression

  • A switching-route test where setActive resolves { error: { status: 429 } }: no recordOrgSwitch call, and the person sees an error, not the spinner. On c94f1fd84 the audit call fires and the spinner stays.
  • A list-panel test renders "Inhaber" for role: 'owner' in German.

Severity and owner

  • Severity: medium. The person is stuck with no explanation, and the audit trail records a switch that didn't happen. The role labels are low.
  • Owner: platform (organizations, shell).
  • Found by: Review A (TALE-358), 2026-10-12 20:15 Zurich occurrence, oldest-due org.switch UX-CLARITY slice. This is static reading at c94f1fd84, verified at the cited lines. I didn't run it, because Review A's stack is BLOCKED.

Activity

  1. added
    agent-ready
    on Oct 29, 2026
  2. added a commit that references this issue on Oct 30, 2026
    c8d9046
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readybug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions