Repository navigation
fix(docx): create document.xml.rels when missing in comment.py - #1790
TINGyu123644 wants to merge 2 commits into
Conversation
add_comment skipped creating word/_rels/document.xml.rels when it was absent, then wrote comments.xml anyway, leaving the comment parts orphaned and unresolvable in Word. Now the relationships part is created with the four comment relationships (rId1-rId4) when missing. Addresses defect 2 in anthropics#1770.
|
Reviewed at head
One change needed — the created part is missing the OPC namespace declaration. It serializes as: <Relationships><Relationship Id="rId1" ... /></Relationships>
Suggested:
Everything else checks out; happy to re-review the updated head. |
minidom keeps the namespace passed to createDocument() in the DOM but does not serialize it, so the created part lacked the xmlns declaration and failed OPC schema validation. Set xmlns explicitly on the root element.
|
Fixed per review: the created part now carries the OPC namespace declaration. Added Re-verified on the new head
|
|
Re-verified at head
All good from my side — thanks for the quick turnaround. |
What changed
skills/docx/scripts/comment.pynow createsword/_rels/document.xml.relswhen it is missing instead of skipping it, registering the four comment relationships (comments.xml,commentsExtended.xml,commentsIds.xml,commentsExtensible.xml) asrId1-rId4.Why
Defect 2 in #1770:
word/_rels/document.xml.relsis optional in a valid minimal DOCX. The old code returned early when it was absent, yetadd_commentcarried on and wrotecomments.xmlplus the satellite comment parts - so the comment part existed with nothing referencing it and Word could not resolve it.How verified
word/_rels/document.xml.relsand ranadd_commentagainst both the old and the fixed code.comments.xmlwritten, relationships part never created (orphaned comments - the reported defect).document.xml.relscreated with exactly the four comment relationships, eachId/Type/Targetmatching_COMMENT_RELS;comments.xmlwritten;python -m py_compileclean.