Sites pane on Organizations & Sites page follows top-bar org switcher instead of in-page selection #709
Replies: 3 comments
-
|
Thanks @bdunncompany — confirmed. The One preference: fold the The Vitest test you described — Open as a draft and I'll review. |
Beta Was this translation helpful? Give feedback.
-
|
Draft PR up at #712. Both call sites renamed; both covered by tests (orgStore.fetchSites assertions updated; new OrganizationsPage.test.tsx asserts the captured Sites URL contains the in-page org id and does NOT contain organizationId=). |
Beta Was this translation helpful? Give feedback.
-
|
Resolved on The fix landed via #732 ( Thanks @bdunncompany. Closing as resolved — reopen if the Sites pane still diverges from the in-page selection on current |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Reproduction
Result: the right pane heading shows "B" (correct), but the Sites table shows org A's sites.
Root cause
OrganizationsPage.fetchSites(apps/web/src/components/settings/OrganizationsPage.tsx:114) calls:fetchWithAuth(apps/web/src/stores/auth.ts:268-275) auto-injectsorgId=<currentOrgId>fromuseOrgStorewhenever the URL does not already contain the literal substringorgId=. Since the page uses the aliasorganizationId=, the injector does not see it and appends&orgId=<top-bar-org>.The API (
apps/api/src/routes/orgs.ts:921-924) then resolves:orgId(the auto-injected top-bar value) wins overorganizationId(the in-page selection), so the server returns sites for the top-bar org. The page heading is local React state and stays correct, which makes the divergence hard to notice in code review.The bug only surfaces when the top-bar and in-page selections disagree. Most callers happen to use both contexts equal, which is why this slipped.
Proposed fix
One-line change: have
OrganizationsPage.fetchSitesuse theorgId=param name directly. The injector will see it and skip re-adding the top-bar context.Optional hardening (separate PR): apply the same rename to
orgStore.fetchSites(apps/web/src/stores/orgStore.ts:172) for consistency, even though that path happens to be benign today.Test: Vitest unit test that mocks
fetchWithAuth, setsuseOrgStore.currentOrgIdto a different value than the in-page selection, and asserts the captured Sites request URL contains the in-page org's id (not the top-bar's).Happy to open the PR if this looks like the right shape.
Beta Was this translation helpful? Give feedback.
All reactions