{"record":{"id":"fadba9adfb1bf8f3","repo":"Significant-Gravitas/AutoGPT","slug":"download-failed-res-status","errorCode":null,"errorMessage":"Download failed: ${res.status}","messagePattern":"Download failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"autogpt_platform/frontend/src/app/(platform)/artifacts/components/ArtifactsList/helpers.ts","lineNumber":44,"sourceCode":"      href: `/copilot?sessionId=${encodeURIComponent(sessionId)}`,\n    };\n  }\n  return { kind: \"builder\", href: \"/build\" };\n}\n\nexport function getFileDownloadUrl(fileId: string): string {\n  return `/api/proxy/api/workspace/files/${encodeURIComponent(fileId)}/download`;\n}\n\n// Fetches the file as a blob and triggers a browser download. Throws on a\n// non-OK response so callers can surface the error (toast) and toggle their\n// own loading state.\nexport async function downloadFileBlob(\n  fileId: string,\n  fileName: string,\n): Promise<void> {\n  const res = await fetch(getFileDownloadUrl(fileId));\n  if (!res.ok) throw new Error(`Download failed: ${res.status}`);\n  const blob = await res.blob();\n  const url = URL.createObjectURL(blob);\n  const a = document.createElement(\"a\");\n  a.href = url;\n  a.download = fileName;\n  document.body.appendChild(a);\n  a.click();\n  a.remove();\n  // Defer revocation so browsers (Firefox/Edge) have time to start the download.\n  setTimeout(() => URL.revokeObjectURL(url), 0);\n}\n\nexport function getFilePreviewUrl(\n  fileId: string,\n  opts: { width?: number; bytes?: number },\n): string {\n  const params = new URLSearchParams();\n  if (opts.width) params.set(\"w\", String(opts.width));","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/frontend/src/app/(platform)/artifacts/components/ArtifactsList/helpers.ts#L26-L62","documentation":"Raised by execute_transfer when tr.status == 'REJECTED'. A rejected transfer can never be executed, even if both approval fields happen to be set (e.g. approved by both sides, then rejected before execution). The check runs after the approval check and before _move_resource.","triggerScenarios":"Both orgs approve, then one rejects before execution, and a party later calls execute. The approval fields are both set, so the earlier checks pass, but the REJECTED status blocks the move.","commonSituations":"Race between reject and execute; UI built from approval fields without also consulting status; retrying an execute after someone rejected in between.","solutions":["Gate execute on status not being REJECTED (or COMPLETED) in addition to checking approvals.","After catching this error, show the user the transfer was rejected and offer creating a new transfer request.","Subscribe to status changes between approval and execution so the UI reflects a late rejection."],"exampleFix":"# before\ntr = await get_transfer(tid)\nif tr.source_approved_by_user_id and tr.target_approved_by_user_id:\n    await execute_transfer(tid, user_id, org_id)\n\n# after\ntr = await get_transfer(tid)\nif tr.status == \"PENDING_BOTH_OR_APPROVED\" and tr.source_approved_by_user_id and tr.target_approved_by_user_id:\n    await execute_transfer(tid, user_id, org_id)\nelse:\n    refresh_ui(tr)","handlingStrategy":"validation","validationCode":"tr = await get_transfer(transfer_id)\nif tr.status == \"REJECTED\":\n    offer_new_transfer()  # cannot execute a rejected transfer","typeGuard":"def is_executable(tr: TransferResponse) -> bool:\n    return tr.status not in (\"COMPLETED\", \"REJECTED\")","tryCatchPattern":"try:\n    await execute_transfer(tid, user_id, org_id)\nexcept ValueError as e:\n    if \"rejected\" in str(e):\n        offer_new_transfer()\n    else:\n        raise","preventionTips":["Check status, not just approval fields, before execute","Re-check status right before execution; reject can land after both approvals"],"tags":["transfers","state-machine","conflict"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}