different-ai/openwork · error
Failed to load organizations.
Error message
Failed to load organizations.
What it means
organization-screen.tsx throws this as the fallback message when `GET /v1/me/orgs` returns a non-ok status and the response payload carries no usable error message. It is the default surfaced to the UI whenever the org list cannot be fetched.
Source
Thrown at ee/apps/den-web/app/(den)/_components/organization-screen.tsx:65
hasMore: orgHasMore,
showMore: showMoreOrgs,
showSearch: showOrgSearch,
} = useOrgListWindow(orgs);
useEffect(() => {
if (!sessionHydrated || !runtimeConfigLoaded) return;
if (!user) {
router.replace("/");
return;
}
let isMounted = true;
async function loadOrgs() {
try {
const { response, payload } = await requestJson("/v1/me/orgs", { method: "GET" });
if (!response.ok) {
throw new Error(getErrorMessage(payload, "Failed to load organizations."));
}
if (isMounted) {
const parsed = parseOrgListPayload(payload);
const nextOrgs = parsed.orgs.map((org) => ({ ...org, isActive: org.slug === parsed.activeOrgSlug }));
const targetOrg = nextOrgs.find((org) => org.isActive) ?? nextOrgs[0] ?? null;
if (isSingleOrgMode && targetOrg) {
router.replace(getOrgDashboardRoute(targetOrg.slug));
return;
}
setOrgs(nextOrgs);
setShowCreate(!isSingleOrgMode && nextOrgs.length === 0);
setBusy(false);
}
} catch (err) {
if (isMounted) {
setError(err instanceof Error ? err.message : "An error occurred.");
setBusy(false);View on GitHub (pinned to 2b7df46e8a)
Solutions
- Check the actual HTTP status of the /v1/me/orgs call in the network tab
- Re-authenticate: sign in again to refresh the session token
- Verify the Den server is running and reachable at the configured base URL
- Add a server-side error body so getErrorMessage returns a meaningful message
Defensive patterns
Strategy: try-catch
Validate before calling
const res = await fetch("/v1/me/orgs");
if (!res.ok) {
console.warn(`org list preflight failed: ${res.status}`);
} Type guard
function isOrgListPayload(p: unknown): p is { orgs: { slug: string }[]; activeOrgSlug: string | null } {
return typeof p === "object" && p !== null && "orgs" in p && Array.isArray((p as { orgs: unknown }).orgs);
} Try / catch
try {
const { response, payload } = await requestJson("/v1/me/orgs", { method: "GET" });
if (!response.ok) throw new Error(getErrorMessage(payload, "Failed to load organizations."));
} catch (err) {
showRetryableError("Could not load your organizations. Check your sign-in and try again.", { retry: loadOrgs });
} Prevention
- Redirect to sign-in proactively on 401 before hitting org endpoints
- Ensure the API always returns a JSON error body with a message field
- Add a loading/retry state to the org screen instead of a bare throw
- Monitor /v1/me/orgs error rates server-side
When it happens
Trigger: `requestJson("/v1/me/orgs", { method: "GET" })` resolves with response.ok === false and getErrorMessage cannot extract a message from the payload (e.g. empty body, HTML error page, non-JSON).
Common situations: Auth token expired/missing so the API returns 401 with an empty body; Den server down or proxying to a 502/503 page; network middleware returning HTML error pages instead of JSON.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
- Failed to create organization.
- Organization was created, but no slug was returned.
- Could not prepare an OpenWork link (${response.status}).
- Failed to update profile (${response.status}).
- Failed to fetch latest-mac.yml (${response.status} ${respons
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/b4cec4d586651b25.
Report an issue: GitHub.