{"record":{"id":"7e503299a190280e","repo":"Comfy-Org/ComfyUI","slug":"failed-to-download-http-resp-status","errorCode":null,"errorMessage":"Failed to download (HTTP {resp.status}).","messagePattern":"Failed to download \\(HTTP (.+?)\\)\\.","errorType":"http","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/download_helpers.py","lineNumber":135,"sourceCode":"                            body = await resp.json()\n                        except (ContentTypeError, ValueError):\n                            text = await resp.text()\n                            body = text if len(text) <= 4096 else f\"[text {len(text)} bytes]\"\n                        request_logger.log_request_response(\n                            operation_id=op_id,\n                            request_method=\"GET\",\n                            request_url=url,\n                            response_status_code=resp.status,\n                            response_headers=dict(resp.headers),\n                            response_content=body,\n                            error_message=f\"HTTP {resp.status}\",\n                        )\n\n                    if resp.status in _RETRY_STATUS and attempt <= max_retries:\n                        await sleep_with_interrupt(delay, cls, None, None, None)\n                        delay *= retry_backoff\n                        continue\n                    raise Exception(f\"Failed to download (HTTP {resp.status}).\")\n\n                if is_path_sink:\n                    p = Path(str(dest))\n                    with contextlib.suppress(Exception):\n                        p.parent.mkdir(parents=True, exist_ok=True)\n                    fhandle = open(p, \"wb\")\n                    sink = fhandle\n                else:\n                    sink = dest  # BytesIO or file-like\n\n                written = 0\n                while True:\n                    try:\n                        chunk = await asyncio.wait_for(resp.content.read(1024 * 1024), timeout=1.0)\n                    except asyncio.TimeoutError:\n                        chunk = b\"\"\n                    except asyncio.CancelledError:\n                        raise ProcessingInterrupted(\"Task cancelled\") from None","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/download_helpers.py#L117-L153","documentation":"A download GET returned an HTTP status >= 400. Statuses in _RETRY_STATUS are retried with backoff up to max_retries; this exception is raised when the status is not retryable or retries are exhausted. The status code is embedded in the message.","triggerScenarios":"404 for an expired/pre-signed media URL (common when a generated asset URL expires before download), 401/403 for auth failures, 429/500/503 that persisted past the retry budget, in comfy_api_nodes/util/download_helpers.py:135.","commonSituations":"Long queues where the download starts after a signed URL's TTL elapsed; invalid or expired API credentials; provider outage returning 5xx for the whole retry window; rate limiting on burst downloads.","solutions":["Map the code: 404 -> the URL expired or is wrong, regenerate/re-fetch the asset URL; 401/403 -> re-authenticate; 429 -> slow down; 5xx -> provider issue, retry later.","Reduce the delay between generation completing and the download step so signed URLs do not expire.","Increase max_retries / backoff for transient 5xx providers.","Check the logged response body (request_logger captures it) for a provider-side error message."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    await download(url, ...)\nexcept Exception as e:\n    msg = str(e)\n    if 'HTTP 404' in msg:\n        url = await refresh_asset_url(asset_id)  # expired presigned URL\n        return await download(url, ...)\n    if 'HTTP 429' in msg:\n        await asyncio.sleep(backoff)\n        return await download(url, ...)\n    raise","preventionTips":["Download generated assets immediately after generation to beat URL TTLs.","Configure sensible max_retries/backoff for the provider's 5xx behavior.","Inspect the logged response body — providers usually explain the error."],"tags":["http","download","retry","presigned-url"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}