different-ai/openwork · error

Failed to load Workflow (${response.status}).

Error message

Failed to load Workflow (${response.status}).

What it means

useWorkflowLibraryDetail is a React Query hook that GETs /v1/workflows/:id and throws 'Failed to load Workflow (STATUS).' when the response is not ok, before parsing via parseWorkflowDetail. The error surfaces through the query's error state so components can render a load-failure message.

Source

Thrown at ee/apps/den-web/app/(den)/dashboard/_components/workflow-detail-data.tsx:62

      automationCount: workflow.automationCount, source: { kind: sourceKind },
    },
    script: workflowDetailSchema.parse(value.script),
    views: value.views.map((view) => generatedArtifactViewSchema.parse(view)),
  };
}

async function mutationJson(path: string, method: "POST" | "PUT") {
  const { response, payload } = await requestJson(path, { method }, 15_000);
  if (!response.ok) throw new Error(getErrorMessage(payload, `Workflow action failed (${response.status}).`));
  return payload;
}

export function useWorkflowLibraryDetail(workflowId: string) {
  return useQuery({
    queryKey: ["workflow", workflowId],
    queryFn: async () => {
      const { response, payload } = await requestJson(`/v1/workflows/${encodeURIComponent(workflowId)}`, { method: "GET" }, 15_000);
      if (!response.ok) throw new Error(getErrorMessage(payload, `Failed to load Workflow (${response.status}).`));
      return parseWorkflowDetail(payload);
    },
  });
}

export function useActivateArtifactView(workflowId: string) {
  const client = useQueryClient();
  return useMutation({
    mutationFn: async ({ viewId, revisionId }: { viewId: string; revisionId: string }) => generatedArtifactViewSchema.parse(await mutationJson(
      `/v1/artifact-views/${encodeURIComponent(viewId)}/revisions/${encodeURIComponent(revisionId)}/activate`,
      "POST",
    )),
    onSuccess: async () => client.invalidateQueries({ queryKey: ["workflow", workflowId] }),
  });
}

export function useRetireArtifactView(workflowId: string) {
  const client = useQueryClient();

View on GitHub (pinned to 2b7df46e8a)

Solutions

  1. Check response.status in the query error and the payload message from getErrorMessage.
  2. If 401/403, re-authenticate or verify the user belongs to the workflow's organization.
  3. If 404, confirm the workflow id is current; refresh the workflow library list.
  4. Retry the query (React Query refetch) if the failure was 5xx or a timeout.
  5. Verify the Den backend/proxy is healthy if all workflows fail to load.

Example fix

// before
const detail = useWorkflowLibraryDetail(workflowId);
// after (caller handles error state)
const detail = useWorkflowLibraryDetail(workflowId);
if (detail.isError) return <ErrorNotice message={detail.error.message} onRetry={detail.refetch} />;
Defensive patterns

Strategy: try-catch

Validate before calling

if (!workflowId) throw new Error("workflowId is required");

Type guard

null

Try / catch

const q = useWorkflowLibraryDetail(id);
if (q.isError) {
  const msg = q.error instanceof Error ? q.error.message : "Failed to load Workflow.";
  if (/\(404\)/.test(msg)) navigateBackToList();
  else return <ErrorNotice message={msg} onRetry={q.refetch} />;
}

Prevention

When it happens

Trigger: GET /v1/workflows/{encodeURIComponent(id)} returns non-2xx: 404 for a deleted or foreign-org workflow id, 401 unauthenticated, 403 no access, 5xx Den backend failure, or requestJson's 15s timeout.

Common situations: Navigating to a workflow detail page for a workflow deleted in another tab, stale deep-link id after org switch, session expiry, Den server restart or proxy 502/504, or a workflow id containing characters that break routing if not encoded.

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/e295f1017a84fc37. Report an issue: GitHub.