{"record":{"id":"7bc9bf1aa79542c6","repo":"docling-project/docling","slug":"libreoffice-did-not-produce-the-expected-output","errorCode":null,"errorMessage":"LibreOffice did not produce the expected output: {converted_path}","messagePattern":"LibreOffice did not produce the expected output: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/backend/docx/drawingml/utils.py","lineNumber":146,"sourceCode":"                [\n                    libreoffice_cmd,\n                    profile_arg,\n                    \"--headless\",\n                    \"--convert-to\",\n                    target_suffix,\n                    \"--outdir\",\n                    str(tmp_dir),\n                    str(input_path),\n                ],\n                stdout=subprocess.DEVNULL,\n                stderr=subprocess.DEVNULL,\n                check=True,\n                timeout=timeout_s,\n            )\n\n        converted_path = tmp_dir / (input_path.stem + \".\" + target_suffix)\n        if not converted_path.exists():\n            raise RuntimeError(\n                f\"LibreOffice did not produce the expected output: {converted_path}\"\n            )\n\n        return BytesIO(converted_path.read_bytes())\n    finally:\n        shutil.rmtree(tmp_dir, ignore_errors=True)\n\n\ndef get_docx_to_pdf_converter() -> Optional[Callable]:\n    \"\"\"\n    Detects the best available DOCX to PDF tool and returns a conversion function.\n    The returned function accepts (input_path, output_path).\n    Returns None if no tool is available.\n    \"\"\"\n\n    # Try LibreOffice\n    libreoffice_cmd = get_libreoffice_cmd()\n","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/docx/drawingml/utils.py#L128-L164","documentation":"convert_with_soffice ran the LibreOffice subprocess successfully (exit code 0, within timeout) but the expected output file tmp_dir/<input-stem>.<target_suffix> does not exist afterwards, so it raises this RuntimeError naming the missing path. This means LibreOffice silently declined to produce that artifact — most often because the input file itself failed to import, or the output landed under a different name/suffix than expected.","triggerScenarios":"A source file (docx/pptx/xlsx) that LibreOffice cannot import (corrupt, password-protected OOXML, or not actually that format) — soffice exits 0 without writing output; case-sensitivity mismatches where LibreOffice writes a different-suffixed file; insufficient disk space or permissions in the temp dir; read-only or locked source under some viewers.","commonSituations":"Password-protected DOCX passed through the drawingml rasterization path; OOXML files produced by non-Office tools that LibreOffice rejects silently; concurrent conversions colliding in temp space; running headless where a modal import filter defaults differently.","solutions":["Open the file manually in LibreOffice (soffice --headless --convert-to pdf file.docx) and see whether it produces output; if not, the file is the problem — repair or re-export it.","Remove password protection from the OOXML file before conversion.","Free space / fix permissions in TMPDIR and pass a writable temp location.","Check for an output written with a different suffix/case in the temp dir to identify naming mismatches, and report upstream if LibreOffice's suffix differs."],"exampleFix":"# before\nconv.convert(Path('drawing.docx'))  # soffice exits 0, no pdf produced\n\n# after (diagnose outside docling first)\n$ soffice --headless --convert-to pdf drawing.docx; ls drawing.pdf\n# if missing -> repair/re-export or decrypt the docx, then rerun docling","handlingStrategy":"try-catch","validationCode":"# Pre-flight the exact conversion outside docling:\nimport subprocess, tempfile, pathlib\n\ndef soffice_can_convert(path: pathlib.Path, target: str = \"pdf\") -> bool:\n    with tempfile.TemporaryDirectory() as td:\n        r = subprocess.run([\"soffice\", \"--headless\", \"--convert-to\", target,\n                            \"--outdir\", td, str(path)],\n                           capture_output=True, timeout=120)\n        return r.returncode == 0 and bool(list(pathlib.Path(td).glob(f\"*.{target}\")))","typeGuard":null,"tryCatchPattern":"try:\n    result = conv.convert(docx_path)\nexcept RuntimeError as e:\n    if \"did not produce the expected output\" in str(e):\n        if not soffice_can_convert(docx_path):\n            quarantine(docx_path)  # file is unopenable by LibreOffice (corrupt/encrypted)\n        else:\n            report_upstream(docx_path, e)  # naming/temp-dir mismatch\n    else:\n        raise","preventionTips":["Remove passwords from OOXML files before conversion.","Smoke-test odd files with soffice --headless --convert-to pdf.","Ensure writable temp space (TMPDIR) and adequate disk for conversions."],"tags":["libreoffice","docx","conversion","silent-failure"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}