different-ai/openwork · error · Error

Failed to load desktop policies (${response.status}).

Error message

Failed to load desktop policies (${response.status}).

What it means

reloadPolicies fetches GET /v1/desktop-policies through requestJson with a 12s timeout. If the Den server responds with a non-OK status, getErrorMessage(payload, fallback) is used: the fallback string `Failed to load desktop policies (${response.status})` surfaces unless the JSON payload carries a more specific message. The caught error is stored in component state via setError, so the message is displayed in the desktop policies screen.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/desktop-policy-data.tsx:174

export function useOrgDesktopPolicies(orgId: string | null) {
  const [definitions, setDefinitions] = useState<DesktopPolicyDefinition[]>([]);
  const [desktopPolicies, setDesktopPolicies] = useState<DenDesktopPolicy[]>([]);
  const [busy, setBusy] = useState(false);
  const [error, setError] = useState<string | null>(null);

  async function reloadPolicies() {
    if (!orgId) {
      setDefinitions([]);
      setDesktopPolicies([]);
      return;
    }

    setBusy(true);
    setError(null);
    try {
      const { response, payload } = await requestJson("/v1/desktop-policies", { method: "GET" }, 12000);
      if (!response.ok) {
        throw new Error(getErrorMessage(payload, `Failed to load desktop policies (${response.status}).`));
      }
      const parsed = parseDesktopPolicyList(payload);
      setDefinitions(parsed.definitions);
      setDesktopPolicies(parsed.desktopPolicies);
    } catch (error) {
      setError(error instanceof Error ? error.message : "Failed to load desktop policies.");
    } finally {
      setBusy(false);
    }
  }

  useEffect(() => {
    void reloadPolicies();
  }, [orgId]);

  return { definitions, desktopPolicies, busy, error, reloadPolicies };
}

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Check the HTTP status in the message and the Den server logs for the matching request; fix the underlying API failure (auth, permissions, or backend).
  2. Re-authenticate: sign out and back in to refresh the Den session, then reload the dashboard.
  3. Verify the account has org admin rights required to read desktop policies.
  4. If the status is 404, upgrade the self-hosted Den server to a version that implements /v1/desktop-policies.
  5. For timeouts, check connectivity to the Den instance and retry.

Example fix

// before (server returns 403, user is member not admin)
await reloadPolicies(); // -> "Failed to load desktop policies (403)."

// after: grant the user the org admin role in Den, then
await reloadPolicies(); // loads definitions + desktopPolicies
Defensive patterns

Strategy: try-catch

Validate before calling

if (!denSessionActive()) redirectToSignIn(); // avoid predictable 401s before reloadPolicies()

Type guard

function isHttpError(e: unknown): e is Error & { status?: number } {
  return e instanceof Error && /\(\d{3}\)/.test(e.message);
}

Try / catch

try {
  await reloadPolicies();
} catch (e) {
  if (isHttpError(e) && e.message.includes("401")) {
    promptReSignIn();
  } else {
    showError(e instanceof Error ? e.message : "Failed to load desktop policies.");
  }
}

Prevention

When it happens

Trigger: GET /v1/desktop-policies returns 401/403 (not signed in or not an org admin), 402 (plan gating on the list endpoint), 404 (server version without the endpoint), 5xx (Den backend failure), or requestJson throws its own timeout/abort error which is caught and replaced by the generic "Failed to load desktop policies." message.

Common situations: Session token expired while the dashboard stayed open; user lacks admin role in the org; self-hosted Den server is an older version without /v1/desktop-policies; Den backend momentarily down; slow network exceeding the 12s timeout.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01). Data as JSON: /api/errors/47887aa979687f64. Report an issue: GitHub.