{"record":{"id":"70f993861019f487","repo":"Comfy-Org/ComfyUI","slug":"upload-io-error","errorCode":"UPLOAD_IO_ERROR","errorMessage":"Failed to receive uploaded file.","messagePattern":"Failed to receive uploaded file\\.","errorType":"http","errorClass":"UploadError","httpStatus":500,"severity":"error","filePath":"app/assets/api/upload.py","lineNumber":103,"sourceCode":"                        500,\n                        \"HASH_CHECK_FAILED\",\n                        \"Backend error while checking asset hash.\",\n                    )\n\n        elif fname == \"file\":\n            file_present = True\n            file_client_name = (field.filename or \"\").strip()\n\n            if provided_hash and provided_hash_exists is True:\n                # Hash exists - drain file but don't write to disk\n                try:\n                    while True:\n                        chunk = await field.read_chunk(8 * 1024 * 1024)\n                        if not chunk:\n                            break\n                        file_written += len(chunk)\n                except Exception:\n                    raise UploadError(\n                        500, \"UPLOAD_IO_ERROR\", \"Failed to receive uploaded file.\"\n                    )\n                continue\n\n            uploads_root = os.path.join(folder_paths.get_temp_directory(), \"uploads\")\n            unique_dir = os.path.join(uploads_root, uuid.uuid4().hex)\n            os.makedirs(unique_dir, exist_ok=True)\n            tmp_path = os.path.join(unique_dir, \".upload.part\")\n\n            try:\n                with open(tmp_path, \"wb\") as f:\n                    while True:\n                        chunk = await field.read_chunk(8 * 1024 * 1024)\n                        if not chunk:\n                            break\n                        f.write(chunk)\n                        file_written += len(chunk)\n            except Exception:","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/app/assets/api/upload.py#L85-L121","documentation":"Raised from the HTTP >=400 branch (comfy_api_nodes/util/client.py:823) via _friendly_http_message when the error body is not a dict (parsed as a JSON list/string or plain text) and its string form is at most 200 characters: 'API Error (raw): {txt}'. The raw body text is passed through so short non-structured error bodies remain readable.","triggerScenarios":"Providers returning short plain-text errors (e.g. 'Forbidden', 'invalid api key') or a JSON string scalar on >=400; minimal gateways that send text bodies; auth layers with terse text denials.","commonSituations":"Simple REST services without structured error JSON; nginx/envoy short text errors; providers with legacy text error endpoints.","solutions":["Read the raw text — short errors like 'invalid api key' are usually self-explanatory","Fix the stated cause (credentials, permissions, payload)","Check the logged status code to map text to the real HTTP semantics","If the text is opaque, query the provider's docs for that exact string"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    result = await sync_op(...)\nexcept Exception as e:\n    if str(e).startswith(\"API Error (raw): \"):\n        handle_text(str(e)[len(\"API Error (raw): \"):])\n    else:\n        raise","preventionTips":["For text-error providers, maintain a mapping from known strings to fixes","Check the logged status code — the text alone may under-specify the failure"],"tags":["http-4xx","text-body","provider","http"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}