Skip to content

fix: find core and extended properties through the root relationships (#457) - #459

Merged
baseballyama merged 2 commits into
mainfrom
fix/issue-457-core-props-rel
Oct 12, 2026
Merged

baseballyama merged 2 commits into
mainfrom
fix/issue-457-core-props-rel

Conversation

@baseballyama

@baseballyama baseballyama commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

getCoreProperties / setCoreProperties and getExtendedProperties / setExtendedProperties now find their parts through the package-root relationships instead of the fixed names /docProps/core.xml and /docProps/app.xml. Packages that store core properties elsewhere (for example package/services/metadata/core-properties/<guid>.psmdcp) previously read as having no properties, and setting them added a second core-properties part and relationship.

Motivation

Reported with a reproduction in #457. OPC (ECMA-376 Part 2) locates the core-properties part by the root relationship of type …/metadata/core-properties, and a package may have at most one; the part name is up to the producer.

Closes #457

Changes

  • The four helpers resolve the part from the internal root relationship of the matching type (relative or absolute target). A part at /docProps/core.xml that no relationship points at is no longer treated as the core properties.
  • When setCoreProperties has to bootstrap, it replaces such an unlinked /docProps/core.xml instead of failing on the name clash, and drops a core-properties relationship whose target part is missing, so the package ends with exactly one relationship and one [Content_Types].xml override (a stale override for a missing part used to be duplicated).
  • If an (invalid) package holds several core-properties relationships, the first whose part exists is used.
  • A relationship target that escapes the package root (../…) throws, as it already does for every other relationship the library resolves.
  • setExtendedProperties still throws when there is no extended-properties part; the message no longer names /docProps/app.xml.
  • Internal: resolveTarget accepts PACKAGE_ROOT as the source for package-root relationships.

Testing

  • test/issue-457-core-properties-rel.test.ts: the issue's reproduction (read + update a moved part, one relationship, no new /docProps/core.xml, validator clean), an absolute relationship target, moved app.xml, an unlinked /docProps/core.xml, a dangling core-properties relationship (one override afterwards), and several relationships with the first dangling. All fail on main.
  • Full suite: pnpm typecheck && pnpm lint && pnpm format:check && pnpm test, plus pnpm --filter @office-kit/pptx-editor test.
pnpm vitest run test/issue-457-core-properties-rel.test.ts

Breaking changes

None. Packages written by this library or the reference desktop app use /docProps/*.xml with a matching relationship and behave as before.

Checklist

  • I have read CLAUDE.md and followed the project's conventions.
  • I have added or updated tests for the change.
  • I have added or updated documentation where user-visible behavior changed.
  • If this is a breaking change, I have added a changeset / CHANGELOG entry and
    flagged it above.
  • I have re-read my own diff and removed dead code, debug prints, and stale
    comments.
  • If I used an LLM to draft this PR, I have verified each change myself, this
    PR represents real work that warrants a maintainer's review, and I am
    willing to defend each line in review.

🤖 Generated with Claude Code

…#457)

OPC locates the core-properties part through the package-root
relationship of that type; `/docProps/core.xml` is only the name the
reference desktop app gives it. Looking the part up by that fixed name
made getCoreProperties return null for packages that store it elsewhere,
and setCoreProperties then bootstrapped a second part and a second
core-properties relationship, which OPC forbids. The extended-properties
helpers had the same fixed-name lookup for `/docProps/app.xml`.

All four helpers now resolve the part from the root relationships.
When setCoreProperties bootstraps, it replaces a part already sitting at
`/docProps/core.xml` that no relationship points at, and drops a
core-properties relationship whose target part is missing, so the
package always ends up with exactly one.

Closes #457

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@baseballyama baseballyama added the bug Something isn't working label Oct 12, 2026
Copilot AI balanced review requested due to automatic review settings October 12, 2026 14:48

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…ling relationship

Also prefer the core-properties relationship whose part exists when an
invalid package holds several.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@baseballyama
baseballyama merged commit 44afe47 into main Oct 12, 2026
16 checks passed
@baseballyama
baseballyama deleted the fix/issue-457-core-props-rel branch October 12, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: core properties are looked up at /docProps/core.xml only; setCoreProperties then adds a second core-properties part

2 participants