different-ai/openwork · error
${fallback} (${response.status}).
Error message
${fallback} (${response.status}). What it means
checkedRequest is workflow-data.tsx's shared wrapper around requestJson: if response.ok is false it throws new Error(getErrorMessage(payload, `${fallback} (${response.status}).`)). Every workflow hook (detail, test, save version, run, delete snapshot, update automation) funnels through it, so the fallback string (e.g. 'Failed to load Workflow') plus status identifies which call failed.
Source
Thrown at ee/apps/den-web/app/(den)/dashboard/_components/workflow-data.tsx:29
export type WorkflowDraft = {
name: string;
description?: string;
code: string;
exampleInput?: unknown;
inputSchema?: unknown;
outputSchema?: unknown;
requiredCapabilities: WorkflowCapability[];
};
const keys = {
detail: (id: string, maxAgeMs: number) => ["workflow", id, "detail", maxAgeMs] as const,
snapshots: (id: string) => ["workflow", id, "snapshots"] as const,
};
async function checkedRequest(path: string, init: RequestInit, fallback: string) {
const { response, payload } = await requestJson(path, init, 170_000);
if (!response.ok) throw new Error(getErrorMessage(payload, `${fallback} (${response.status}).`));
return payload;
}
export function useWorkflowDetail(configObjectId: string, maxAgeMs: number) {
return useQuery({
queryKey: keys.detail(configObjectId, maxAgeMs),
queryFn: async () => {
const payload = await checkedRequest(
`/v1/workflows/${encodeURIComponent(configObjectId)}?maxAgeMs=${maxAgeMs}`,
{ method: "GET" },
"Failed to load Workflow",
);
if (typeof payload !== "object" || payload === null || !("script" in payload)) throw new Error("The Workflow response was invalid.");
return workflowDetailSchema.parse(payload.script);
},
enabled: Boolean(configObjectId),
});
}View on GitHub (pinned to 2b7df46e8a)
Solutions
- Read response.status in the thrown message: 404 → the workflow id no longer exists, refresh the list; 401/403 → re-auth or request access.
- For test/run timeouts, check whether the gateway (not the workflow) returned 504 and raise the gateway timeout or shorten the run.
- Retry transient 5xx; invalidate the workflow query keys afterward.
- Confirm the configObjectId passed to the hook matches an existing workflow.
Example fix
// before
if (!response.ok) throw new Error(getErrorMessage(payload, `${fallback} (${response.status}).`));
// after
if (!response.ok) {
if (response.status >= 500) throw new RetryableError(getErrorMessage(payload, `${fallback} (${response.status}).`));
throw new Error(getErrorMessage(payload, `${fallback} (${response.status}).`));
} Defensive patterns
Strategy: try-catch
Validate before calling
function assertWorkflowId(id: string): boolean {
return typeof id === "string" && id.length > 0;
} Type guard
function isApiErrorPayload(v: unknown): v is { error?: string; message?: string } {
return isRecord(v) && (typeof v.error === "string" || typeof v.message === "string");
} Try / catch
try {
await runWorkflow(id);
} catch (e) {
const msg = e instanceof Error ? e.message : "";
if (msg.includes("(404)")) await invalidateAndRefreshList();
else if (msg.includes("(401)") || msg.includes("(403)")) promptAuth();
else if (msg.includes("(504)")) showTimeoutNotice();
else throw e;
} Prevention
- Refresh workflow ids from the list endpoint rather than long-lived local state
- Configure gateway timeouts above the 170s requestJson budget for test/run calls
- Classify retryable (5xx) vs permanent (4xx) errors in query retry logic
When it happens
Trigger: Any workflow API call returning non-2xx: GET detail/snapshots 404 (unknown configObjectId), 401/403 auth, 409 conflict on save, 5xx on run/test; long-running test/run timing out at the 170s requestJson budget with a gateway 504.
Common situations: Workflow deleted elsewhere while the dashboard holds a stale id; permissions changed; server restart during a 170s test run; API deploy causing transient 5xx.
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
- Failed to load desktop policies (${response.status}).
- Could not load egress diagnostics (${response.status}).
- Egress diagnostic could not start (${response.status}).
- Failed to load inference settings (${response.status}).
- Failed to load dashboards (${response.status}).
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/861a2d1113b9e155.
Report an issue: GitHub.