{"record":{"id":"86cdabf25e312305","repo":"opendatalab/MinerU","slug":"invalid-pptx-package-file-is-not-a-zip-archive","errorCode":null,"errorMessage":"Invalid PPTX package: file is not a ZIP archive.","messagePattern":"Invalid PPTX package: file is not a ZIP archive\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mineru/model/pptx/package_normalizer.py","lineNumber":121,"sourceCode":"            for info in source.infolist():\n                member_data = _read_member_best_effort(source, info)\n                if member_data is None:\n                    skipped_members.add(info.filename)\n                    changed = True\n                    continue\n                loaded_members.append((info, member_data))\n\n            for info, member_data in loaded_members:\n                normalized_data = _normalize_member_xml(\n                    info.filename,\n                    member_data,\n                    skipped_members,\n                )\n                if normalized_data != member_data:\n                    changed = True\n                rewritten_members.append((info, normalized_data))\n    except BadZipFile as exc:\n        raise ValueError(\"Invalid PPTX package: file is not a ZIP archive.\") from exc\n\n    if not changed:\n        return file_bytes\n\n    return _write_package(rewritten_members)\n\n\ndef _read_member_best_effort(source: ZipFile, info: ZipInfo) -> bytes | None:\n    \"\"\"读取 ZIP 成员；损坏的媒体资源可跳过，关键 XML/关系文件仍保持失败。\"\"\"\n    try:\n        return source.read(info.filename)\n    except BadZipFile as exc:\n        if _is_skippable_corrupt_member(info.filename):\n            logger.warning(\n                f\"Skipping corrupt non-critical PPTX media member {info.filename}: {exc}\"\n            )\n            return None\n        raise","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/model/pptx/package_normalizer.py#L103-L139","documentation":"The PPTX normalizer opens the input with ZipFile; a zipfile.BadZipFile escapes the reader and is re-raised as ValueError('Invalid PPTX package: file is not a ZIP archive.'). Every OOXML file (.pptx) is a ZIP, so this means the bytes are not a .pptx at all.","triggerScenarios":"Passing a legacy .ppt (OLE2), an RTF/HTML file renamed to .pptx, a password-protected/encrypted OOXML package (which is stored as an OLE container), or a truncated download.","commonSituations":"Upload endpoints trusting the client-supplied extension, partially downloaded or interrupted transfers, files exported as strict OOXML but corrupted by transfer encoding.","solutions":["Verify the first bytes are 'PK\\\\x03\\\\x04' before parsing.","Re-obtain the file (re-download, re-export) if truncated.","If it starts with D0 CF 11 E0, it is either legacy .ppt (convert it) or an encrypted package (decrypt then parse)."],"exampleFix":"# before\ndata = open(f'{name}.pptx','rb').read()  # actually legacy bytes\nnormalize_pptx_package(data)\n\n# after\nif not data.startswith(b'PK\\\\x03\\\\x04'):\n    raise SystemExit('not a pptx zip; convert first')\nnormalize_pptx_package(data)","handlingStrategy":"validation","validationCode":"def is_zip_package(data: bytes) -> bool:\n    return data[:4] == b'PK\\\\x03\\\\x04'","typeGuard":null,"tryCatchPattern":"try:\n    normalize_pptx_package(data)\nexcept ValueError as e:\n    if 'not a ZIP archive' in str(e):\n        # decide: legacy OLE2 -> convert; truncated -> re-fetch\n        raise\n    raise","preventionTips":["Check the PK signature on every uploaded 'pptx'.","Reject 0-byte and truncated uploads by Content-Length checks.","Keep downloads atomic (temp file + rename) to avoid truncated packages."],"tags":["pptx","file-format","zip","document-parsing"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}