{"record":{"id":"1e6cd2fdec552f52","repo":"Significant-Gravitas/AutoGPT","slug":"invalid-file-type-allowed-jpeg-png-webp-got","errorCode":null,"errorMessage":"Invalid file type. Allowed: JPEG, PNG, WebP. Got: {content_type}","messagePattern":"Invalid file type\\. Allowed: JPEG, PNG, WebP\\. Got: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"autogpt_platform/backend/backend/api/features/oauth.py","lineNumber":708,"sourceCode":"        not (app := await get_oauth_application_by_id(app_id))\n        or app.owner_id != user_id\n    ):\n        raise HTTPException(\n            status_code=status.HTTP_404_NOT_FOUND,\n            detail=\"OAuth App not found\",\n        )\n\n    # Check GCS configuration\n    if not settings.config.media_gcs_bucket_name:\n        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,","sourceCodeStart":690,"sourceCodeEnd":726,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/oauth.py#L690-L726","documentation":"Returned (400) when the uploaded file's declared Content-Type is not in LOGO_ALLOWED_TYPES (JPEG, PNG, WebP). The check uses the multipart header value, not the file's magic bytes, so the label on the part must be one of the allowed MIME types.","triggerScenarios":"Uploading image/svg+xml, image/gif, image/bmp, application/octet-stream, or a mislabeled part (e.g. sending PNG bytes with content type text/plain).","commonSituations":"Designers exporting SVG or GIF logos; generic HTTP clients defaulting to application/octet-stream; renaming a .gif to .png without changing the MIME header (the header, not extension, is checked).","solutions":["Convert the logo to JPEG, PNG, or WebP before uploading","Set the multipart part's Content-Type explicitly (image/png, image/jpeg, or image/webp)","Do not rely on the file extension — the declared MIME type must match"],"exampleFix":"# before\ncurl -F \"logo=@logo.svg\" ...\n# after\ncurl -F \"logo=@logo.png;type=image/png\" ...","handlingStrategy":"validation","validationCode":"ALLOWED = {\"image/jpeg\", \"image/png\", \"image/webp\"}\nif file.content_type not in ALLOWED:\n    raise ValueError(f\"convert to JPEG/PNG/WebP first, got {file.content_type}\")","typeGuard":"def is_allowed_logo_type(content_type: str) -> bool:\n    return content_type in {\"image/jpeg\", \"image/png\", \"image/webp\"}","tryCatchPattern":"if resp.status_code == 400 and \"Invalid file type\" in resp.text:\n        prompt_user_to_convert_image()","preventionTips":["Convert assets to PNG/WebP in the pipeline, never trust user file labels","Set explicit part content types in HTTP clients","Detect format from magic bytes client-side, not from extensions"],"tags":["validation","http-400","file-upload","mime-type"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}