{"record":{"id":"520987e43dab8000","repo":"windmill-labs/windmill","slug":"get-path-resp-status","errorCode":null,"errorMessage":"GET ${path} -> ${resp.status}","messagePattern":"GET (.+?) -> (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/sync/sync.ts","lineNumber":4555,"sourceCode":"  workspaceId: string,\n  sinceIso: string,\n  changedPaths: string[],\n): Promise<{ pending: number; failed: { path: string; error?: string }[] }> {\n  // A dependency job's script_path has no file extension; changed paths do.\n  const belongsToPush = (scriptPath?: string) =>\n    !!scriptPath &&\n    changedPaths.some(\n      (p) => p === scriptPath || p.startsWith(scriptPath + \".\"),\n    );\n  // Raw fetch: the checked-in generated client predates the `created_after` /\n  // `success` filters on the job list routes (see the `apiGet` note in\n  // pipeline.ts).\n  const listJobs = async (path: string): Promise<unknown[]> => {\n    const { OpenAPI } = await import(\"../../../gen/index.ts\");\n    const resp = await fetch(`${OpenAPI.BASE}${path}`, {\n      headers: { ...getHeaders(), Authorization: `Bearer ${OpenAPI.TOKEN}` },\n    });\n    if (!resp.ok) throw new Error(`GET ${path} -> ${resp.status}`);\n    return (await resp.json()) as unknown[];\n  };\n  try {\n    const since = encodeURIComponent(sinceIso);\n    const [queued, completed] = await Promise.all([\n      listJobs(\n        `/w/${workspaceId}/jobs/queue/list?job_kinds=dependencies&created_after=${since}`,\n      ),\n      listJobs(\n        `/w/${workspaceId}/jobs/completed/list?job_kinds=dependencies&created_after=${since}&success=false`,\n      ),\n    ]);\n    const pending = (queued as { script_path?: string }[]).filter((j) =>\n      belongsToPush(j.script_path),\n    ).length;\n    const failed = (completed as { script_path?: string; result?: unknown }[])\n      .filter((j) => belongsToPush(j.script_path))\n      .map((j) => ({","sourceCodeStart":4537,"sourceCodeEnd":4573,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/sync/sync.ts#L4537-L4573","documentation":"The sync job-polling helper listJobs() performs a raw fetch against the Windmill API (OpenAPI.BASE + path) with auth headers and throws 'GET <path> -> <status>' when the HTTP response is not ok. It surfaces non-2xx statuses (401 unauthorized, 404 wrong workspace/path, 5xx server errors) that the generated OpenAPI client would otherwise wrap, during the flow runs polling done by sync.","triggerScenarios":"`wmill sync` background polling calls listJobs for queued/completed runs and the server returns a non-OK status — expired/invalid token (401), wrong workspace in the URL (404), rate limiting (429), or server error (500/502/503).","commonSituations":"Token expired mid-sync; remote/server restarted or behind a proxy returning 502; wrong --workspace or --base-url so the jobs endpoint 404s; temporary server overload (5xx) during a long sync.","solutions":["Read the status in the message: 401 → re-authenticate (`wmill auth login` or refresh token); 404 → verify workspace and base URL; 5xx → check server health/logs and retry","Re-run the sync command after restoring auth or server availability","Check REMOTE/base-url configuration — a proxy returning 502 means the backend is down or the port is wrong","If 429, back off and retry later; reduce polling frequency if you control the client"],"exampleFix":"// before (no retry)\nconst jobs = await listJobs(path);\n// after\ntry {\n  const jobs = await listJobs(path);\n} catch (e) {\n  if (String(e).includes('-> 5')) await sleep(2000), retry();\n  else throw e;\n}","handlingStrategy":"retry","validationCode":"const resp = await fetch(`${OpenAPI.BASE}${jobsPath}`, { method: 'HEAD', headers: getHeaders() });\nif (!resp.ok) throw new Error(`API unavailable: ${resp.status} — fix auth/URL before syncing`);","typeGuard":null,"tryCatchPattern":"try {\n  const jobs = await listJobs(path);\n} catch (e) {\n  const m = /GET .* -> (\\d+)/.exec(String(e));\n  const status = m?.[1];\n  if (status === '401') reauth();\n  else if (status?.startsWith('5') || status === '429') await backoffRetry();\n  else throw e;\n}","preventionTips":["Refresh auth tokens before long sync runs","Verify --workspace and base URL match the target instance","Check server health (and proxies/ports) when seeing 5xx during sync"],"tags":["http","api","network","sync","polling"],"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"}