{"record":{"id":"0e2b15c946b29a23","repo":"Significant-Gravitas/AutoGPT","slug":"invalid-image-file","errorCode":null,"errorMessage":"Invalid image file","messagePattern":"Invalid image file","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/oauth.py","lineNumber":761,"sourceCode":"\n        if width < LOGO_MIN_SIZE:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail=f\"Logo too small. Minimum {LOGO_MIN_SIZE}x{LOGO_MIN_SIZE}. \"\n                f\"Got {width}x{height}\",\n            )\n\n        if width > LOGO_MAX_SIZE:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail=f\"Logo too large. Maximum {LOGO_MAX_SIZE}x{LOGO_MAX_SIZE}. \"\n                f\"Got {width}x{height}\",\n            )\n    except HTTPException:\n        raise\n    except Exception as e:\n        logger.error(f\"Error validating logo image: {e}\")\n        raise HTTPException(\n            status_code=status.HTTP_400_BAD_REQUEST,\n            detail=\"Invalid image file\",\n        )\n\n    # Scan for viruses\n    filename = file.filename or \"logo\"\n    await scan_content_safe(file_bytes, filename=filename)\n\n    # Generate unique filename\n    file_ext = os.path.splitext(filename)[1].lower() or \".png\"\n    unique_filename = f\"{uuid.uuid4()}{file_ext}\"\n    storage_path = f\"oauth-apps/{app_id}/logo/{unique_filename}\"\n\n    # Upload to GCS\n    try:\n        async with async_storage.Storage() as async_client:\n            bucket_name = settings.config.media_gcs_bucket_name\n","sourceCodeStart":743,"sourceCodeEnd":779,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/oauth.py#L743-L779","documentation":"Returned (400) when Pillow's Image.open or the dimension checks raise an unexpected exception — i.e. the bytes are not a decodable image at all (corrupt, truncated, or a non-image payload with an image MIME type). The real exception is logged server-side; HTTPException subclasses are re-raised untouched so the specific dimension errors above still surface.","triggerScenarios":"Uploading a renamed text file as logo.png, a truncated download, a zero-byte file, or an image format Pillow cannot decode (e.g. some TIFF/HEIC variants) while declaring an allowed content type.","commonSituations":"Manual renames of non-image files; interrupted downloads; HEIC photos from iPhones passed through with image/jpeg label.","solutions":["Re-export or re-download the image from a trusted source and verify it opens in an image viewer","Convert HEIC/ exotic formats to PNG or WebP before uploading","Check backend logs for the logged Pillow exception to confirm the decode failure"],"exampleFix":"# python - validate locally before upload\nfrom PIL import Image\nimg = Image.open(\"logo.png\"); img.verify()  # raises here, not on the server","handlingStrategy":"validation","validationCode":"from PIL import Image\nimg = Image.open(path)\nimg.verify()  # raises on corrupt/truncated files before upload","typeGuard":"def is_decodable_image(path: str) -> bool:\n    try:\n        Image.open(path).verify()\n        return True\n    except Exception:\n        return False","tryCatchPattern":"if resp.status_code == 400 and \"Invalid image file\" in resp.text:\n        ask_user_for_new_source_file()","preventionTips":["Run Pillow verify() client-side before any upload","Convert HEIC/raw formats to PNG/WebP","Never rename non-image files to image extensions"],"tags":["validation","http-400","image","corrupt-file"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}