apache/superset · error · IncorrectFormatError

Not a ZIP file

Error message

Not a ZIP file

What it means

IncorrectFormatError('Not a ZIP file') raised by the chart import endpoint (POST /api/v1/chart/import/): the uploaded formData file is checked with zipfile.is_zipfile(), and anything without a valid ZIP magic/signature is rejected before the bundle is opened. Superset chart exports are distributed as ZIP archives containing YAML/JSON files, so this guard catches wrong file types at the boundary.

Source

Thrown at superset/charts/api.py:1579

                  schema:
                    type: object
                    properties:
                      message:
                        type: string
            400:
              $ref: '#/components/responses/400'
            401:
              $ref: '#/components/responses/401'
            422:
              $ref: '#/components/responses/422'
            500:
              $ref: '#/components/responses/500'
        """
        upload = request.files.get("formData")
        if not upload:
            return self.response_400()
        if not is_zipfile(upload):
            raise IncorrectFormatError("Not a ZIP file")
        with ZipFile(upload) as bundle:
            contents = get_contents_from_bundle(bundle)

        if not contents:
            raise NoValidFilesFoundError()

        passwords = (
            json.loads(request.form["passwords"])
            if "passwords" in request.form
            else None
        )
        overwrite = request.form.get("overwrite") == "true"
        ssh_tunnel_passwords = (
            json.loads(request.form["ssh_tunnel_passwords"])
            if "ssh_tunnel_passwords" in request.form
            else None
        )
        ssh_tunnel_private_keys = (

View on GitHub (pinned to f4587218dd)

Solutions

  1. Upload the ZIP bundle produced by the export endpoint (GET/POST /api/v1/chart/export/), not its unpacked contents.
  2. If you have loose YAML files, zip them first: zip bundle.zip *.yaml (keeping the expected directory layout).
  3. Verify locally before uploading: `file bundle.zip` should report 'Zip archive data' or `python -c "from zipfile import is_zipfile; print(is_zipfile('bundle.zip'))"`.
  4. Check proxy/client body-size limits if uploads arrive truncated.

Example fix

# before
curl -F 'formData=@chart.yaml' -H "Authorization: Bearer $T" \
  http://superset:8088/api/v1/chart/import/

# after
zip bundle.zip chart.yaml
curl -F 'formData=@bundle.zip' -H "Authorization: Bearer $T" \
  http://superset:8088/api/v1/chart/import/
Defensive patterns

Strategy: validation

Validate before calling

from zipfile import is_zipfile

with open(path, "rb") as f:
    if not is_zipfile(f):
        raise SystemExit(f"{path} is not a ZIP archive; export bundles must be zipped")

Prevention

When it happens

Trigger: Uploading a raw YAML/JSON export file, a .tar.gz, or a renamed non-ZIP file as formData to the import endpoint; uploading a truncated ZIP cut off by a proxy's body-size limit; multipart requests where the wrong part is picked because the field name differs and a text part is passed.

Common situations: Users exporting from older Superset versions or other tools that emit different archive formats; curl invocations where -F formData=@chart.yaml points at the inner file instead of the bundle; files corrupted in transit or by upload limits.

Related errors


AI-assisted analysis of apache/superset@f4587218dd (2026-08-14). Data as JSON: /api/errors/3ae806001bdbd585. Report an issue: GitHub.