Significant-Gravitas/AutoGPT · error · HTTPException
Invalid image file
Error message
Invalid image file
What it means
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.
Source
Thrown at autogpt_platform/backend/backend/api/features/oauth.py:761
if width < LOGO_MIN_SIZE:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"Logo too small. Minimum {LOGO_MIN_SIZE}x{LOGO_MIN_SIZE}. "
f"Got {width}x{height}",
)
if width > LOGO_MAX_SIZE:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"Logo too large. Maximum {LOGO_MAX_SIZE}x{LOGO_MAX_SIZE}. "
f"Got {width}x{height}",
)
except HTTPException:
raise
except Exception as e:
logger.error(f"Error validating logo image: {e}")
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid image file",
)
# Scan for viruses
filename = file.filename or "logo"
await scan_content_safe(file_bytes, filename=filename)
# Generate unique filename
file_ext = os.path.splitext(filename)[1].lower() or ".png"
unique_filename = f"{uuid.uuid4()}{file_ext}"
storage_path = f"oauth-apps/{app_id}/logo/{unique_filename}"
# Upload to GCS
try:
async with async_storage.Storage() as async_client:
bucket_name = settings.config.media_gcs_bucket_name
View on GitHub (pinned to 9c8bb5550f)
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
Example fix
# python - validate locally before upload
from PIL import Image
img = Image.open("logo.png"); img.verify() # raises here, not on the server Defensive patterns
Strategy: validation
Validate before calling
from PIL import Image img = Image.open(path) img.verify() # raises on corrupt/truncated files before upload
Type guard
def is_decodable_image(path: str) -> bool:
try:
Image.open(path).verify()
return True
except Exception:
return False Try / catch
if resp.status_code == 400 and "Invalid image file" in resp.text:
ask_user_for_new_source_file() Prevention
- Run Pillow verify() client-side before any upload
- Convert HEIC/raw formats to PNG/WebP
- Never rename non-image files to image extensions
When it happens
Trigger: 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.
Common situations: Manual renames of non-image files; interrupted downloads; HEIC photos from iPhones passed through with image/jpeg label.
Related errors
- Logo must be square. Got {width}x{height}
- Logo too small. Minimum {LOGO_MIN_SIZE}x{LOGO_MIN_SIZE}. Got
- Logo too large. Maximum {LOGO_MAX_SIZE}x{LOGO_MAX_SIZE}. Got
- start and end query params are required
- str(exc)
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/0e2b15c946b29a23.
Report an issue: GitHub.