fix(pptx): add retry, timeout, and lock cleanup to thumbnail soffice conversion#982
Open
voidborne-d wants to merge 1 commit intoanthropics:mainfrom
Open
fix(pptx): add retry, timeout, and lock cleanup to thumbnail soffice conversion#982voidborne-d wants to merge 1 commit intoanthropics:mainfrom
voidborne-d wants to merge 1 commit intoanthropics:mainfrom
Conversation
…conversion thumbnail.py's convert_to_images() called soffice once with no retry, no timeout, no --norestore, and no stderr capture. In containerized environments (Docker, sandboxed VMs), LibreOffice fails intermittently due to stale lock files, concurrent processes, or profile corruption. The only error message was 'PDF conversion failed' with zero diagnostics. Changes: - Add retry loop (3 attempts) with lock file cleanup between retries - Add --norestore flag (parity with xlsx/scripts/recalc.py) - Add 120s timeout to both soffice and pdftoppm subprocess calls - Surface stderr in RuntimeError messages for debugging - Add _cleanup_soffice_lock() helper to remove stale .~lock.* files New tests: 18 regression tests covering retry logic, timeout handling, lock file cleanup, error message quality, and source-level audits. Closes anthropics#886
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #886 —
thumbnail.py'sconvert_to_images()callssoffice --headless --convert-to pdfonce with no retry, no timeout, no--norestoreflag, and no stderr capture. In containerized environments (Docker, sandboxed VMs), LibreOffice fails intermittently due to stale lock files, concurrent processes, or profile corruption. The only error message was a bare"PDF conversion failed"with zero diagnostics.Root Cause
The
xlsx/scripts/recalc.pyin this same repo already uses--norestoreand timeouts for its soffice calls, butpptx/scripts/thumbnail.pywas written without these safeguards. The discrepancy means thumbnail generation is fragile in exactly the environments where the PPTX skill is most commonly used (containerized Claude Code sessions).Changes
skills/pptx/scripts/thumbnail.py--norestoreflag: prevents LibreOffice from trying to recover a previous session (parity withrecalc.py)pdftoppmcallRuntimeErrormessages now include the actual soffice/pdftoppm stderr output for debugging_cleanup_soffice_lock()helper: removes stale.~lock.*files from both the temp dir and the default LibreOffice user profile between retriesskills/pptx/scripts/tests/test_thumbnail_soffice_retry.py(new)18 regression tests organized in 3 test classes:
--norestoreis present,timeout=is set on both subprocess calls, retry/timeout constants are defined, lock cleanup function exists, no bare error messages without stderr detail remain, and pdftoppm has timeout--norestoreflag presence in actual command listAll tests use lightweight stubs (no PIL/defusedxml/soffice required), suitable for CI.
Testing
python3 -m pytest skills/pptx/scripts/tests/test_thumbnail_soffice_retry.py -v # 18 passed