Repository navigation
fix(docx): report LibreOffice timeout as an error and verify the output - #1792
TINGyu123644 wants to merge 2 commits into
Conversation
accept_changes returned "Successfully accepted all tracked changes" when soffice timed out, leaving the output in an unknown state. Timeouts now return an Error, and success is only claimed after checking that the output DOCX no longer carries revision marks. Addresses defect 1 in anthropics#1770.
|
Reviewed at head
One fix needed — the marker match is prefix-based and flags clean documents. Same with Otherwise the direction is right — fail on timeout, verify the postcondition before claiming success. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
This check is tied to the literal w: prefix, but OOXML namespace prefixes aren't semantic. A valid revision serialized as <x:ins ...> with the WordprocessingML namespace will be missed and the output reported clean. Could this parse the XML and match namespace URI + local name instead of raw prefixes?
|
Cross-check on the tightening suggestions for
So the parse approach raised in the latest review covers both failure classes. If you take it, please keep the current fail-closed default ( |
Match revision marks (ins/del/moveFrom/moveTo) by WordprocessingML namespace URI + local name instead of the literal w: prefix, so documents that bind the namespace to a different prefix are still detected as containing tracked changes.
|
Thanks for the review! I've updated It now parses each |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Rechecked current 54b1981. The namespace-prefix issue I raised is resolved: tracked-change elements are now parsed by WordprocessingML namespace URI plus local name, so aliased prefixes are detected while clean elements such as insideH/instrText are no longer false positives. Parse failures still fail closed. No remaining blocker from my review.
|
Hi @sylvesterkaczmarek — just a quick check-in: the namespace-URI rewrite has been approved and the branch is up to date with main. Is there anything else needed before this can be merged (e.g. a rebase or an additional review)? Happy to do whatever is required. |
|
Nothing else is needed from my review. My approval on |
|
Thanks for re-confirming the approval — nothing further needed on my end. Happy for this to be merged whenever you have a moment. |
What changed
skills/docx/scripts/accept_changes.pynow returns an Error whensofficetimes out instead of reporting success, and only claims success after checking that the output DOCX no longer carries revision marks (w:ins/w:del/w:moveFrom/w:moveTo) inword/*.xmlparts.Why
Defect 1 in #1770:
sofficeoperates in place on a copy and the macro stores/closes the document itself, so a timeout leaves the output in an unknown state (possibly untouched, possibly partly processed) while the caller was told "Successfully accepted all tracked changes".__main__keys on"Error" in message, so the process also exited 0.How verified
LibreOffice is not installed in this environment, so the fix is verified with mocked
subprocess.runplus real DOCX fixtures:subprocess.TimeoutExpired): returns an Error mentioning the timeout, never "Successfully".returncode == 0but the output still contains<w:ins>: returns "tracked changes remain in output document".returncode == 0with a clean output DOCX: still reports success._docx_still_has_tracked_changes: True for each revision marker (w:ins,w:del,w:moveFrom,w:moveTo) and for a non-zip file, False for a clean DOCX.python -m py_compileclean; no new third-party imports (zipfileis stdlib).The macro-setup path (
_setup_libreoffice_macro) is untouched.