{"record":{"id":"e59b6a32152b8fac","repo":"windmill-labs/windmill","slug":"failed-to-queue-dependencies-job-queueresponse","errorCode":null,"errorMessage":"Failed to queue dependencies job: ${queueResponse.status} ${queueResponse.statusText}, ${bodyText}","messagePattern":"Failed to queue dependencies job: (.+?) (.+?), (.+?)","errorType":"exception","errorClass":"LockfileGenerationError","httpStatus":null,"severity":"error","filePath":"cli/src/utils/metadata.ts","lineNumber":643,"sourceCode":"          ? rawWorkspaceDependencies : null,\n        entrypoint: remotePath,\n        temp_script_refs: tempScriptRefs && Object.keys(tempScriptRefs).length > 0\n          ? tempScriptRefs : null,\n      }),\n    }\n  );\n\n  await detectAuthGatewayChallenge(\n    queueResponse,\n    `${workspace.remote}api/w/${workspace.workspaceId}/jobs/run/dependencies_async`,\n  );\n\n  if (!queueResponse.ok) {\n    let bodyText = \"\";\n    try {\n      bodyText = await queueResponse.text();\n    } catch { /* ignore */ }\n    throw new LockfileGenerationError(\n      `Failed to queue dependencies job: ${queueResponse.status} ${queueResponse.statusText}, ${bodyText}`\n    );\n  }\n\n  const jobId = (await queueResponse.text()).trim();\n\n  let completion;\n  try {\n    completion = await pollJobWithQueueLogging(\n      workspace.workspaceId,\n      jobId,\n      { label: `deps ${remotePath}` },\n    );\n  } catch (e: any) {\n    throw new LockfileGenerationError(\n      `Failed to poll dependencies job ${jobId}: ${e?.message ?? e}`\n    );\n  }","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/utils/metadata.ts#L625-L661","documentation":"fetchScriptLock queues a `dependencies_async` job on the Windmill server to generate a script's lockfile remotely. This LockfileGenerationError is thrown when the HTTP POST that queues that job returns a non-2xx status; the server's HTTP status, status text and response body are embedded in the message so the underlying API rejection is visible. It is the CLI's way of surfacing a server-side or network-level rejection of the lockfile-generation request before any job is even created.","triggerScenarios":"Any non-ok response from POST {remote}/api/w/{workspaceId}/jobs/run/dependencies_async: invalid/expired workspace token (401), missing permissions on the workspace (403), unknown workspace id (404), malformed request payload (422), worker/queue unavailable or server error (5xx), or a proxy/gateway intercepting the request with an HTML error page.","commonSituations":"Stale WM_TOKEN after token rotation or logout; pointing `remote` at a reverse proxy or SSO gateway that returns a login/HTML page instead of the API; wrong workspace id in workspace config; Windmill server temporarily down or overloaded (502/503 from load balancer); enterprise ACLs denying the 'dependencies_async' endpoint.","solutions":["Run `wmill workspace switch` (or re-add the workspace with a fresh token) to fix expired/invalid credentials, then retry","Verify the workspace remote URL points at the Windmill API root and not through an SSO gateway or proxy that injects HTML (check `wmill workspace` list)","Confirm the workspace id and your token's permissions (the token must be allowed to run jobs in that workspace)","Check the Windmill server is healthy and workers are running (status endpoint / instance admin); retry after transient 5xx","Read the bodyText portion of the message — it contains the server's JSON error explaining the exact rejection"],"exampleFix":"// before: raw fetch failing with opaque error\nconst res = await fetch(url, { method: \"POST\", headers, body });\n// after: pre-validate auth and surface actionable message\nconst res = await fetch(url, { method: \"POST\", headers, body });\nif (res.status === 401 || res.status === 403) {\n  throw new LockfileGenerationError(\n    `Token rejected by ${workspace.remote} (${res.status}); run 'wmill workspace switch' to refresh credentials`\n  );\n}","handlingStrategy":"try-catch","validationCode":"// pre-flight: verify the workspace token is accepted before queueing\nconst who = await fetch(`${workspace.remote}api/users/whoami`, {\n  headers: { Cookie: `token=${workspace.token}` },\n});\nif (!who.ok) {\n  throw new Error(\n    `Workspace token invalid for ${workspace.workspaceId} (HTTP ${who.status}); run 'wmill workspace switch' first`\n  );\n}","typeGuard":"function isOkResponse(res: Response): res is Response & { ok: true } {\n  return res.ok;\n}\n// usage:\n// if (!isOkResponse(queueResponse)) { handle non-2xx safely }","tryCatchPattern":"try {\n  const lock = await fetchScriptLock(workspace, content, language, path, deps);\n} catch (e) {\n  if (e instanceof LockfileGenerationError && e.message.includes(\"Failed to queue dependencies job: 401\")) {\n    log.error(\"Token rejected — refresh credentials with `wmill workspace switch`\");\n  } else if (e instanceof LockfileGenerationError && / 5\\d\\d /.test(e.message)) {\n    log.error(\"Windmill server error — retry shortly\");\n  } else {\n    throw e;\n  }\n}","preventionTips":["Refresh workspace tokens regularly and before long sync/push operations (`wmill workspace switch`)","Check `wmill workspace` shows the correct remote and workspace id before pushing","Avoid routing the remote through SSO gateways/proxies that rewrite API responses","Monitor instance health (workers running) when pushing large dependency sets","Always read the bodyText in the error — it carries the server's exact rejection reason"],"tags":["network","http","cli","windmill"],"backgroundTag":"http-request-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}