Skip to content

Read documents that have no relationships part - #196

Merged
satoryu merged 1 commit into
masterfrom
fix-192-missing-rels
Oct 17, 2026
Merged

satoryu merged 1 commit into
masterfrom
fix-192-missing-rels

Conversation

@satoryu

@satoryu satoryu commented Oct 17, 2026

Copy link
Copy Markdown
Member

Bug

Document#load_rels already rescues a missing word/_rels/document*.xml.rels and leaves @rels nil. But #hyperlink_relationships then called @rels.xpath without a nil check. So #hyperlinks, and with it #document_properties, #paragraphs, #tables, #to_s and #to_html, raised NoMethodError for such documents.

Fix

When @rels is nil, #hyperlink_relationships returns an empty NodeSet, so #hyperlinks returns {} and the document reads normally. This mirrors the missing-styles.xml handling from #158.

Tests

  • New fixture_without(name, *entries) spec helper: rebuilds a fixture in memory with the given zip entries dropped, so this needs no new binary fixture.
  • Two new cases in spec/docx/document_spec.rb on basic.docx without its rels part: #hyperlinks is {}, and paragraphs / html are still read.

Closes #192

🤖 Generated with Claude Code

load_rels already rescues a missing word/_rels/document*.xml.rels and
leaves @RELS nil, but hyperlink_relationships then called @rels.xpath,
so #hyperlinks, and with it #paragraphs/#tables/#to_s, raised
NoMethodError. Return an empty NodeSet instead, so #hyperlinks is {}.

Add a fixture_without spec helper that drops zip entries from a fixture
in memory, so such documents need no extra binary fixture.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@satoryu
satoryu merged commit acd4935 into master Oct 17, 2026
6 checks passed
@satoryu
satoryu deleted the fix-192-missing-rels branch October 17, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document without word/_rels/document.xml.rels raises NoMethodError on #paragraphs

1 participant