different-ai/openwork · error
Organization not found.
Error message
Organization not found.
What it means
ensureActiveOrganizationSelected in org-dashboard-provider.tsx guards all org mutations (settings update, delete, invites, seat checkout, invitation cancel, role change). It throws 'Organization not found.' when neither the active organization nor the org context provides an id, meaning the provider cannot determine which organization to act on.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_providers/org-dashboard-provider.tsx:107
const [orgSettingsCompletion, setOrgSettingsCompletion] = useState<OrgSettingsCompletion | null>(null);
const pendingReauthMutationsRef = useRef<PendingReauthMutation[]>([]);
const pathnameRef = useRef(pathname);
const [reauthDialogOpen, setReauthDialogOpen] = useState(false);
const activeOrg = useMemo(
() =>
orgDirectory.find((entry) => entry.isActive) ??
orgDirectory[0] ??
null,
[orgDirectory],
);
const activeOrgId = activeOrg?.id ?? orgContext?.organization.id ?? null;
const isSingleOrgMode = runtimeConfigLoaded && runtimeConfig.orgMode === "single_org";
function ensureActiveOrganizationSelected() {
if (!activeOrgId) {
throw new Error("Organization not found.");
}
}
function getCurrentAccess() {
return getOrgAccessFlags(
orgContext?.currentMember.role ?? "member",
orgContext?.currentMember.isOwner ?? false,
orgContext?.roles,
);
}
function ensureCanManageSettings() {
if (!getCurrentAccess().canManageSettings) {
throw new Error("Only workspace owners and super-admins can change settings.");
}
}
function ensureCanDeleteOrganization() {View on GitHub (pinned to 2b7df46e8a)
Solutions
- Wait for runtimeConfigLoaded and orgContext to resolve before enabling mutation UI (disable buttons until ready).
- Check why the org context fetch failed (auth, network) and reload the dashboard.
- Verify the account actually belongs to an organization; create/join one if not.
- Guard call sites with an activeOrgId check instead of calling the mutation directly.
- Refresh the page to re-run the org context bootstrap.
Example fix
// before await updateOrganizationSettings(orgId, settings); // after if (!activeOrgId) return; // or show org-picker await updateOrganizationSettings(orgId, settings);
Defensive patterns
Strategy: validation
Validate before calling
if (!activeOrgId) { showToast("Select an organization first"); return; }
await mutation(...); Type guard
null
Try / catch
try {
await updateOrganizationSettings(orgId, settings);
} catch (e) {
if (e instanceof Error && e.message === "Organization not found.") {
await refreshOrgContext(); // re-bootstrap, then retry or prompt org picker
} else throw e;
} Prevention
- Gate mutation UI on runtimeConfigLoaded && activeOrgId != null.
- Never fire org mutations from effects before context hydration completes.
- Handle failed org-context fetches visibly instead of silently leaving activeOrgId null.
- Show an org picker when the user has no active organization.
When it happens
Trigger: Calling any wrapped mutation before the runtime config has loaded or before orgContext resolves (activeOrgId null), e.g. invoking updateOrganizationSettings or inviteMember during initial mount, after a failed /me fetch, or in an org-less account state.
Common situations: Autosave or a scheduled action firing before org context hydration, a user with no organization membership, org context fetch failing silently (network/auth), single_org mode with runtimeConfig not yet loaded, or stale UI rendered before context load.
Related errors
- The workspace owner cannot be changed or removed from this a
- This cloud provider has not been imported into the workspace
- Sign in to OpenWork Cloud and choose an organization first.
- The active OpenWork Cloud account changed while reconnecting
- Marketplace package is not installed in this workspace.
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/ad939e83e509155e.
Report an issue: GitHub.