{"record":{"id":"56e9f06f24a885e5","repo":"anthropics/skills","slug":"1","errorCode":null,"errorMessage":"1","messagePattern":"1","errorType":"error_code","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"skills/docx/scripts/accept_changes.py","lineNumber":135,"sourceCode":"        logger.warning(f\"Failed to setup LibreOffice macro: {e}\")\n        return False\n\n\nif __name__ == \"__main__\":\n    parser = argparse.ArgumentParser(\n        description=\"Accept all tracked changes in a DOCX file\"\n    )\n    parser.add_argument(\"input_file\", help=\"Input DOCX file with tracked changes\")\n    parser.add_argument(\n        \"output_file\", help=\"Output DOCX file (clean, no tracked changes)\"\n    )\n    args = parser.parse_args()\n\n    _, message = accept_changes(args.input_file, args.output_file)\n    print(message)\n\n    if \"Error\" in message:\n        raise SystemExit(1)\n","sourceCodeStart":117,"sourceCodeEnd":136,"githubUrl":"https://github.com/anthropics/skills/blob/f6656c1256d5a8adfa37db9110046ef20bac644c/skills/docx/scripts/accept_changes.py#L117-L136","documentation":"This is not a raised exception but a process exit: the CLI prints the result message from accept_changes() and, if the message contains the substring 'Error', exits with status 1 via raise SystemExit(1). The message '1' seen by callers is therefore the nonzero exit code, indicating the operation failed (typically a missing/invalid input file or a LibreOffice 'soffice' subprocess failure captured in the message text). Inspect the printed message on stdout/stderr for the underlying cause.","triggerScenarios":"Running `python accept_changes.py in.docx out.docx` where accept_changes() returns a message containing 'Error' — e.g. the input file does not exist, is not a valid DOCX, the soffice binary is missing from PATH, or LibreOffice exits nonzero (result.returncode != 0 with 'Error: LibreOffice failed: ...' stderr).","commonSituations":"Headless servers without LibreOffice installed; a stale or locked LibreOffice user profile (-env:UserInstallation) causing soffice to fail; passing a .doc/.odt or corrupt file instead of a real DOCX; wrong argument order so the input path points at a nonexistent file.","solutions":["Re-run the script and read the printed message — it names the actual failure (missing file, invalid DOCX, or LibreOffice stderr).","Verify the input path exists and is a valid .docx (unzip -l shows word/document.xml).","Confirm LibreOffice is installed and 'soffice' is on PATH ('soffice --headless --version').","If the LibreOffice profile is corrupted, remove the profile directory referenced by LIBREOFFICE_PROFILE so the macro setup recreates it."],"exampleFix":"# before\nsubprocess.run([\"python\", \"accept_changes.py\", \"in.docx\", \"out.docx\"], check=True)\n\n# after\nproc = subprocess.run([\"python\", \"accept_changes.py\", \"in.docx\", \"out.docx\"], capture_output=True, text=True)\nif proc.returncode != 0:\n    print(proc.stdout)  # message names the real failure\n    # handle: fix input file or install LibreOffice","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport shutil, subprocess\n\ndef can_accept_changes(input_file: str) -> tuple[bool, str]:\n    p = Path(input_file)\n    if not p.is_file():\n        return False, f\"input not found: {p}\"\n    import zipfile\n    try:\n        with zipfile.ZipFile(p) as zf:\n            if \"word/document.xml\" not in zf.namelist():\n                return False, \"not a valid .docx (missing word/document.xml)\"\n    except zipfile.BadZipFile:\n        return False, \"not a zip/OOXML file\"\n    if not shutil.which(\"soffice\"):\n        return False, \"LibreOffice (soffice) not on PATH\"\n    return True, \"ok\"","typeGuard":null,"tryCatchPattern":"# subprocess caller pattern\nimport subprocess\nproc = subprocess.run([sys.executable, \"accept_changes.py\", inp, outp], capture_output=True, text=True)\nif proc.returncode != 0:\n    log.error(\"accept_changes failed: %s\", proc.stdout.strip())  # printed message has the cause\n    # do NOT retry unchanged; fix input/env first","preventionTips":["Validate the input is a real DOCX (zip containing word/document.xml) before invoking.","Install LibreOffice and verify 'soffice --headless --version' works in the execution environment.","Always capture and log stdout of the script — the exit code carries no detail, the message does.","Run in a clean, writable LibreOffice user profile to avoid lock corruption."],"tags":["cli","exit-code","libreoffice","docx","process"],"backgroundTag":null,"analyzedSha":"f6656c1256d5a8adfa37db9110046ef20bac644c","analyzedAt":"2026-08-14T16:09:17.493Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}