Comfy-Org/ComfyUI · error · UploadError

UNSUPPORTED_MEDIA_TYPE

UNSUPPORTED_MEDIA_TYPE

Error message

Use multipart/form-data for uploads.

What it means

Raised from the HTTP >=400 branch (comfy_api_nodes/util/client.py:823) via _friendly_http_message when the error body is a JSON dict with an error object containing both 'message' and 'type' fields. The message embeds the provider's own error text and machine-readable type, e.g. validation failures, invalid parameters, or provider-side processing errors.

Source

Thrown at app/assets/api/upload.py:42

async def parse_multipart_upload(
    request: web.Request,
    check_hash_exists: Callable[[str], bool],
) -> ParsedUpload:
    """
    Parse a multipart/form-data upload request.

    Args:
        request: The aiohttp request
        check_hash_exists: Callable(hash_str) -> bool to check if a hash exists

    Returns:
        ParsedUpload with parsed fields and temp file path

    Raises:
        UploadError: On validation or I/O errors
    """
    if not (request.content_type or "").lower().startswith("multipart/"):
        raise UploadError(
            415, "UNSUPPORTED_MEDIA_TYPE", "Use multipart/form-data for uploads."
        )

    reader = await request.multipart()

    file_present = False
    file_client_name: str | None = None
    tags_raw: list[str] = []
    provided_name: str | None = None
    user_metadata_raw: str | None = None
    provided_hash: str | None = None
    provided_hash_exists: bool | None = None
    provided_mime_type: str | None = None
    provided_preview_id: str | None = None

    file_written = 0
    tmp_path: str | None = None

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Read the embedded message and type — they state exactly which parameter or condition failed
  2. Correct the offending input per the provider's error text and rerun
  3. Cross-check the node's parameter definitions against the provider's current API docs if the error persists
  4. Check the logged full response body for extra fields beyond message/type
Defensive patterns

Strategy: try-catch

Validate before calling

import json
def validate_generation_params(p):
    assert 64 <= p.width <= 2048 and 64 <= p.height <= 2048, "size out of range"
    assert p.model in SUPPORTED_MODELS, "unknown model id"

Try / catch

try:
    result = await sync_op(...)
except Exception as e:
    m = re.match(r"API Error: (.+) \(Type: (.+)\)", str(e))
    if m and m.group(2) == "invalid_request_error":
        fix_param(m.group(1))
    else:
        raise

Prevention

When it happens

Trigger: Sending invalid/oversized parameters to a provider endpoint (bad resolution, missing required field, unsupported model name); content rejected by provider validation; any 4xx/5xx whose body follows the {"error": {"message", "type"}} shape.

Common situations: Node parameter mismatches after a provider API update; user-entered values (dimensions, seeds, model ids) outside allowed ranges; changed required fields.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/4fc12ef7f93542a1. Report an issue: GitHub.