{"record":{"id":"84a7ba291a5b33b8","repo":"Significant-Gravitas/AutoGPT","slug":"failed-to-read-uploaded-file","errorCode":null,"errorMessage":"Failed to read uploaded file","messagePattern":"Failed to read uploaded file","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/oauth.py","lineNumber":718,"sourceCode":"        raise HTTPException(\n            status_code=status.HTTP_503_SERVICE_UNAVAILABLE,\n            detail=\"Media storage is not configured\",\n        )\n\n    # Validate content type\n    content_type = file.content_type\n    if content_type not in LOGO_ALLOWED_TYPES:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=f\"Invalid file type. Allowed: JPEG, PNG, WebP. Got: {content_type}\",\n        )\n\n    # Read file content\n    try:\n        file_bytes = await file.read()\n    except Exception as e:\n        logger.error(f\"Error reading logo file: {e}\")\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Failed to read uploaded file\",\n        )\n\n    # Check file size\n    if len(file_bytes) > LOGO_MAX_FILE_SIZE:\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=(\n                \"File too large. \"\n                f\"Maximum size is {LOGO_MAX_FILE_SIZE // 1024 // 1024}MB\"\n            ),\n        )\n\n    # Validate image dimensions\n    try:\n        image = Image.open(io.BytesIO(file_bytes))\n        width, height = image.size","sourceCodeStart":700,"sourceCodeEnd":736,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/oauth.py#L700-L736","documentation":"Returned (400) when reading the multipart file body raises an exception (await file.read() fails). The underlying error is logged server-side; the client only sees the generic message. Causes are typically aborted/truncated uploads or framework-level read errors.","triggerScenarios":"Client disconnects mid-upload, connection reset while streaming the multipart body, malformed multipart encoding, or upstream proxy truncating the request.","commonSituations":"Reverse proxy (nginx/traefik) with a body size limit cutting the stream; flaky mobile networks aborting uploads; hand-rolled multipart payloads with wrong part boundaries.","solutions":["Retry the upload over a stable connection","Check reverse proxy client_max_body_size / request buffering settings","Inspect backend logs for the logged underlying exception to identify the real cause"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if file.size is not None and file.size <= 0:\n    raise ValueError(\"empty or unreadable file\")","typeGuard":null,"tryCatchPattern":"if resp.status_code == 400 and \"Failed to read\" in resp.text:\n    backoff_and_retry(max_attempts=2)","preventionTips":["Raise proxy body-size limits above the app's 3MB logo cap","Verify file integrity locally before upload","Use resumable/stable connections for uploads"],"tags":["file-upload","http-400","network"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}