{"record":{"id":"2dc39fda9cf63a36","repo":"apache/superset","slug":"not-a-valid-zip-file","errorCode":null,"errorMessage":"Not a valid ZIP file","messagePattern":"Not a valid ZIP file","errorType":"exception","errorClass":"DatabaseUploadFailed","httpStatus":422,"severity":"error","filePath":"superset/commands/database/uploaders/columnar_reader.py","lineNumber":91,"sourceCode":"        except Exception as ex:\n            raise DatabaseUploadFailed(_(\"Error reading Columnar file\")) from ex\n\n    @staticmethod\n    def _yield_files(file: FileStorage) -> Generator[IO[bytes], None, None]:\n        \"\"\"\n        Yields files from the provided file. If the file is a zip file, it yields each\n        file within the zip file. If it's a single file, it yields the file itself.\n\n        :param file: The file to yield files from.\n        :return: A generator that yields files.\n        \"\"\"\n        file_suffix = Path(file.filename).suffix\n        if not file_suffix:\n            raise DatabaseUploadFailed(_(\"Unexpected no file extension found\"))\n        file_suffix = file_suffix[1:]  # remove the dot\n        if file_suffix == \"zip\":\n            if not is_zipfile(file):\n                raise DatabaseUploadFailed(_(\"Not a valid ZIP file\"))\n            try:\n                with ZipFile(file) as zip_file:\n                    # guard against decompression bombs before reading entries,\n                    # mirroring the importer path\n                    try:\n                        check_is_safe_zip(zip_file)\n                    except SupersetException as ex:\n                        raise DatabaseUploadFailed(str(ex)) from ex\n                    # check if all file types are of the same extension\n                    file_suffixes = {Path(name).suffix for name in zip_file.namelist()}\n                    if len(file_suffixes) > 1:\n                        raise DatabaseUploadFailed(\n                            _(\"ZIP file contains multiple file types\")\n                        )\n                    for filename in zip_file.namelist():\n                        with zip_file.open(filename) as file_in_zip:\n                            yield BytesIO(file_in_zip.read())\n            except BadZipfile as ex:","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/apache/superset/blob/f4587218dd19d046c3e4d00063e7d27f8a2ed354/superset/commands/database/uploaders/columnar_reader.py#L73-L109","documentation":"DatabaseUploadFailed ('Not a valid ZIP file') raised in ColumnarReader._yield_files when the uploaded filename ends in .zip but zipfile.is_zipfile(file) returns False — the stream does not start with a valid ZIP End-of-Central-Directory / local file header signature.","triggerScenarios":"Uploading a file named *.zip that is not a ZIP archive: a renamed Parquet or CSV file, a truncated download, an S3 pre-signed response saved as .zip, or an HTML error page saved with a .zip extension.","commonSituations":"Users renaming files to force the wrong reader; interrupted downloads (ZIP central directory is at the end and missing when truncated); proxy/CDN error responses (XML AccessDenied from S3) saved as .zip.","solutions":["Verify the file locally: 'file data.zip' should report 'Zip archive data'","Re-download/re-export the archive if it was truncated or is actually an error payload","If the payload is a single Parquet file, rename it to .parquet instead of .zip"],"exampleFix":"# shell check\nfile upload.zip   # 'Zip archive data' -> ok; anything else -> not a zip","handlingStrategy":"validation","validationCode":"import zipfile\n\ndef is_valid_zip(fh) -> bool:\n    fh.seek(0)\n    return zipfile.is_zipfile(fh)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify with 'file data.zip' before upload","Never rename non-zip files to .zip","For single parquet files, upload as .parquet instead of wrapping in a fake zip"],"tags":["zip","file-upload","validation"],"backgroundTag":null,"analyzedSha":"f4587218dd19d046c3e4d00063e7d27f8a2ed354","analyzedAt":"2026-08-14T22:39:27.425Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}