apache/superset · error · IncorrectFormatError

Not a ZIP file

Error message

Not a ZIP file

What it means

Raised by the database import endpoint (POST /api/v1/database/import/) when the uploaded formData is not a ZIP: is_zipfile() inspects the stream's magic bytes and rejects anything else. Unlike the dashboard import endpoint, this API does not accept a single non-ZIP file.

Source

Thrown at superset/databases/api.py:1671

                  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. Zip the export files locally (zip databases.zip database.yaml) and upload that archive.
  2. Confirm the file starts with 'PK' magic bytes: xxd upload.bin | head -1.
  3. Re-download the export if it may have been corrupted in transit.

Example fix

# before
python -c "import requests; requests.post(url, files={'formData': open('database.yaml','rb')})"

# after
python -c "import zipfile; zipfile.ZipFile('import.zip','w').write('database.yaml')"
python -c "import requests; requests.post(url, files={'formData': open('import.zip','rb')})"
Defensive patterns

Strategy: validation

Validate before calling

import zipfile
def is_zip(path: str) -> bool:
    return zipfile.is_zipfile(path)

Try / catch

from superset.commands.import_exceptions import IncorrectFormatError
try:
    client.post("/api/v1/database/import/", files={"formData": f})
except IncorrectFormatError:
    raise SystemExit("database import requires a ZIP bundle")

Prevention

When it happens

Trigger: POST /api/v1/database/import/ with a bare YAML/JSON file, a tar.gz, or a corrupt/truncated ZIP whose central directory is missing.

Common situations: Uploading database.yaml directly instead of zipping the export bundle; gzip'd exports; file corrupted by a proxy or by text-mode transfer.

Related errors


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