{"record":{"id":"0eaff8b390ce1925","repo":"run-llama/liteparse","slug":"str-e","errorCode":null,"errorMessage":"{str(e)}","messagePattern":"\\{str\\(e\\)\\}","errorType":"exception","errorClass":"ParseError","httpStatus":null,"severity":"error","filePath":"packages/python/liteparse/parser.py","lineNumber":739,"sourceCode":"            source = f\"<{len(file_data)} bytes>\"\n        else:\n            file_path = Path(file_data)\n            if not file_path.exists():\n                raise FileNotFoundError(f\"File not found: {file_path}\")\n            payload = str(file_path.absolute())\n            source = payload\n\n        if self._pool is not None:\n            return self._pool.parse(payload, source)\n\n        try:\n            if isinstance(payload, bytes):\n                native_result = self._native.parse_bytes(payload)\n            else:\n                native_result = self._native.parse(payload)\n            return _convert_native_result(native_result)\n        except Exception as e:\n            raise ParseError(str(e)) from e\n\n    def parse_batches(\n        self,\n        file_data: Union[str, Path, bytes],\n        batch_size: Optional[int] = None,\n    ) -> Iterator[ParseBatch]:\n        \"\"\"\n        Parse a document in bounded-memory page batches.\n\n        Each yielded batch is an ordinary :class:`ParseResult` covering\n        ``batch.start_page`` through ``batch.end_page``, and becomes\n        collectible as soon as you advance the iterator — so a loop that does\n        not retain batches never holds more than one batch of pages in memory.\n        A non-PDF source is converted once, not once per batch.\n\n        Cross-page passes see only the pages in their own batch, so repeated\n        header/footer removal and image deduplication are batch-local and the\n        output can differ from :meth:`parse`. Prefer :meth:`parse` unless the","sourceCodeStart":721,"sourceCodeEnd":757,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/packages/python/liteparse/parser.py#L721-L757","documentation":"LiteParse wraps every exception raised by the native parsing backend into a ParseError, chaining the original exception via `from e`. This means any failure during PDF loading, conversion, or extraction (corrupt files, unsupported formats, native crashes reported as errors) surfaces here as a single ParseError whose message is the native error text.","triggerScenarios":"Calling LiteParse.parse() (with a path or bytes) when the native backend fails: corrupt or encrypted PDF, unsupported/corrupt office file passed to conversion, PDFium extraction failure, or any native binding panic surfaced as a Python exception.","commonSituations":"Passing a file with a wrong extension that LibreOffice conversion cannot handle; parsing a scanned PDF without OCR enabled; a truncated download; memory exhaustion on very large documents.","solutions":["Read the chained original exception (`raise ... from e`) — inspect `e.__cause__` for the native root cause","Verify the input file opens in a standard PDF viewer / is a supported format","If the document is image-only, enable OCR in the LiteParse config","Update the package; if reproducible with a minimal file, report the bug with the input"],"exampleFix":"// before\nresult = parser.parse('report.pdf')  # opaque ParseError\n// after\ntry:\n    result = parser.parse('report.pdf')\nexcept ParseError as e:\n    log.error('parse failed: %s (cause: %r)', e, e.__cause__)","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\np = Path(file_data)\nif not p.is_file():\n    raise FileNotFoundError(p.resolve())","typeGuard":"def is_parseable_input(data: object) -> bool:\n    return isinstance(data, bytes) or (isinstance(data, (str, Path)) and Path(data).is_file())","tryCatchPattern":"try:\n    result = parser.parse(file_data)\nexcept ParseError as e:\n    root = e.__cause__\n    logger.error('parse failed: %s (cause: %r)', e, root)\n    raise","preventionTips":["Always inspect e.__cause__ to get the real native failure","Validate the file exists and is a regular file before parsing","Enable OCR for scanned/image-only PDFs","Keep the package updated; native PDFium bugs are fixed in releases"],"tags":["python","pdf","error-wrapping"],"backgroundTag":"native-parse-failed","analyzedSha":"22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8","analyzedAt":"2026-09-08T06:09:49.009Z","contentChangedAt":"2026-09-08T06:09:49.009Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}