{"record":{"id":"4240b54189c82fc1","repo":"apache/superset","slug":"not-a-zip-file-4240b5","errorCode":null,"errorMessage":"Not a ZIP file","messagePattern":"Not a ZIP file","errorType":"exception","errorClass":"IncorrectFormatError","httpStatus":422,"severity":"error","filePath":"superset/databases/api.py","lineNumber":1671,"sourceCode":"                  schema:\n                    type: object\n                    properties:\n                      message:\n                        type: string\n            400:\n              $ref: '#/components/responses/400'\n            401:\n              $ref: '#/components/responses/401'\n            422:\n              $ref: '#/components/responses/422'\n            500:\n              $ref: '#/components/responses/500'\n        \"\"\"\n        upload = request.files.get(\"formData\")\n        if not upload:\n            return self.response_400()\n        if not is_zipfile(upload):\n            raise IncorrectFormatError(\"Not a ZIP file\")\n        with ZipFile(upload) as bundle:\n            contents = get_contents_from_bundle(bundle)\n\n        if not contents:\n            raise NoValidFilesFoundError()\n\n        passwords = (\n            json.loads(request.form[\"passwords\"])\n            if \"passwords\" in request.form\n            else None\n        )\n        overwrite = request.form.get(\"overwrite\") == \"true\"\n        ssh_tunnel_passwords = (\n            json.loads(request.form[\"ssh_tunnel_passwords\"])\n            if \"ssh_tunnel_passwords\" in request.form\n            else None\n        )\n        ssh_tunnel_private_keys = (","sourceCodeStart":1653,"sourceCodeEnd":1689,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/databases/api.py#L1653-L1689","documentation":"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.","triggerScenarios":"POST /api/v1/database/import/ with a bare YAML/JSON file, a tar.gz, or a corrupt/truncated ZIP whose central directory is missing.","commonSituations":"Uploading database.yaml directly instead of zipping the export bundle; gzip'd exports; file corrupted by a proxy or by text-mode transfer.","solutions":["Zip the export files locally (zip databases.zip database.yaml) and upload that archive.","Confirm the file starts with 'PK' magic bytes: xxd upload.bin | head -1.","Re-download the export if it may have been corrupted in transit."],"exampleFix":"# before\npython -c \"import requests; requests.post(url, files={'formData': open('database.yaml','rb')})\"\n\n# after\npython -c \"import zipfile; zipfile.ZipFile('import.zip','w').write('database.yaml')\"\npython -c \"import requests; requests.post(url, files={'formData': open('import.zip','rb')})\"","handlingStrategy":"validation","validationCode":"import zipfile\ndef is_zip(path: str) -> bool:\n    return zipfile.is_zipfile(path)","typeGuard":null,"tryCatchPattern":"from superset.commands.import_exceptions import IncorrectFormatError\ntry:\n    client.post(\"/api/v1/database/import/\", files={\"formData\": f})\nexcept IncorrectFormatError:\n    raise SystemExit(\"database import requires a ZIP bundle\")","preventionTips":["Always zip database export files before upload — this endpoint accepts no single files.","Check the PK magic bytes when generating bundles programmatically."],"tags":["import","database","zip","upload"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}