{"record":{"id":"7b363de4c0365ed2","repo":"agentscope-ai/agentscope","slug":"failed-to-parse-filename-r-as-pptx-e","errorCode":null,"errorMessage":"Failed to parse {filename!r} as PPTX: {e}","messagePattern":"Failed to parse (.+?) as PPTX: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/agentscope/rag/_parser/_ppt.py","lineNumber":212,"sourceCode":"        \"\"\"\n        if isinstance(file, str):\n            with open(file, \"rb\") as fp:\n                file = fp.read()\n\n        try:\n            from pptx import Presentation\n        except ImportError as e:\n            raise ImportError(\n                \"Please install python-pptx to use the PowerPoint \"\n                \"parser. You can install it by \"\n                \"`pip install python-pptx` (or \"\n                \"`pip install agentscope[rag]`).\",\n            ) from e\n\n        try:\n            prs = Presentation(io.BytesIO(file))\n        except Exception as e:  # pylint: disable=broad-except\n            raise ValueError(\n                f\"Failed to parse {filename!r} as PPTX: {e}\",\n            ) from e\n\n        sections: list[Section] = []\n        for slide_idx, slide in enumerate(prs.slides):\n            sections.extend(\n                self._parse_slide(slide, slide_idx, filename),\n            )\n        return sections\n\n    # ------------------------------------------------------------------\n    # Slide-level parsing\n    # ------------------------------------------------------------------\n\n    def _parse_slide(\n        self,\n        slide: Any,\n        slide_idx: int,","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/agentscope-ai/agentscope/blob/e90f1c7592896cc95f6e5ee506194f533378247d/src/agentscope/rag/_parser/_ppt.py#L194-L230","documentation":"The PPTX parser wraps python-pptx's Presentation() failure: the provided bytes/path could not be loaded as a valid PowerPoint file. It is a ValueError raised during parse() when the underlying library throws any exception while opening the file.","triggerScenarios":"Calling PPTParser.parse() (directly or via build_index) with a file that is not a valid .pptx — e.g. a .ppt (legacy binary), a .docx, a zero-byte/corrupt file, or a password-protected presentation.","commonSituations":"Users pointing a RAG pipeline at an Office directory containing legacy .ppt files, files downloaded incompletely, or renamed non-PPTX files; missing python-pptx install also surfaces nearby.","solutions":["Verify the file is actually OOXML .pptx (unzip -l file.pptx should show ppt/slides/)","Filter or convert legacy .ppt files before parsing (e.g. with LibreOffice: soffice --convert-to pptx)","Validate the magic bytes (PK\\x03\\x04 zip signature) before calling parse","Install rag extras: pip install 'agentscope[rag]'"],"exampleFix":"// before\nsections = ppt_parser.parse(path)  # raises for legacy .ppt\n// after\nif open(path,'rb').read(4) != b'PK\\x03\\x04':\n    raise SkipFile(path)\nsections = ppt_parser.parse(path)","handlingStrategy":"validation","validationCode":"import zipfile\npath = 'deck.pptx'\nvalid = zipfile.is_zipfile(path) and zipfile.ZipFile(path).namelist().count('[Content_Types].xml') >= 0 and any(n.startswith('ppt/slides/') for n in zipfile.ZipFile(path).namelist())","typeGuard":"def is_pptx(path: str) -> bool:\n    return zipfile.is_zipfile(path)","tryCatchPattern":"try:\n    sections = parser.parse(path)\nexcept ValueError as e:\n    if 'as PPTX' in str(e): logger.warning('skipping invalid pptx %s', path)\n    else: raise","preventionTips":["Filter corpus to .pptx (not .ppt) before indexing","Convert legacy .ppt with LibreOffice first","Check zip magic bytes before parsing"],"tags":["pptx","parsing","rag","file-format"],"backgroundTag":"invalid-file-format","analyzedSha":"e90f1c7592896cc95f6e5ee506194f533378247d","analyzedAt":"2026-08-28T18:24:12.087Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}