Repository navigation
bug: core properties are looked up at /docProps/core.xml only; setCoreProperties then adds a second core-properties part #457
Description
Summary
getCoreProperties / setCoreProperties read the core-properties part from the fixed name /docProps/core.xml instead of following the package's core-properties relationship. For a valid package that stores the part under another name, the getter returns null and the setter adds a second core-properties part and relationship.
Reproduction
Starts from a deck the library creates and moves the core-properties part to another name, updating the root relationship and the content-type override so the package stays valid (OPC locates this part through the relationship of type http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties, not by name).
import * as lib from "@office-kit/pptx";
import { unzipSync, zipSync, strToU8, strFromU8 } from "fflate";
const p0 = lib.createPresentation();
lib.setCoreProperties(p0, { title: "Quarterly review" });
const files = unzipSync(await lib.savePresentation(p0));
const moved = "package/services/metadata/core-properties/abc.psmdcp";
files[moved] = files["docProps/core.xml"];
delete files["docProps/core.xml"];
for (const name of ["_rels/.rels", "[Content_Types].xml"]) {
files[name] = strToU8(strFromU8(files[name]).replaceAll("docProps/core.xml", moved));
}
const pres = await lib.loadPresentation(zipSync(files));
console.log("title:", lib.getCoreProperties(pres)?.title);
lib.setCoreProperties(pres, { title: "Renamed" });
const out = unzipSync(await lib.savePresentation(pres));
console.log("core-properties relationships:", strFromU8(out["_rels/.rels"]).match(/relationships\/metadata\/core-properties/g).length);
console.log("core-properties parts:", Object.keys(out).filter((n) => n === moved || n === "docProps/core.xml"));Expected behavior
getCoreProperties(pres).titleis"Quarterly review".setCorePropertiesupdates the existing part, and the package keeps one core-properties relationship (OPC allows at most one).
Actual behavior
title: undefined
core-properties relationships: 2
core-properties parts: [
'package/services/metadata/core-properties/abc.psmdcp',
'docProps/core.xml'
]
getCoreProperties returns null, and setCoreProperties bootstraps a new /docProps/core.xml with a second core-properties relationship beside the original.
Cause, from the shipped source: src/api/fn/properties.ts defines CORE_PROPS_PART_NAME = partName('/docProps/core.xml'), and both getCoreProperties and setCoreProperties call pkg.getPart(CORE_PROPS_PART_NAME). The relationship is consulted only when the setter creates the part. Unchanged on main.
Environment
- Package version: 0.24.0 (latest release)
- Runtime: Node 24.19.0 on Windows 11 x64
- Other relevant details:
fflate0.8.3 is used only by the repro, to edit the package parts
Additional context
We hit this with a template from another producer that stores core properties under package/services/metadata/core-properties/<guid>.psmdcp. PowerPoint itself always uses docProps/core.xml.
Confirmation
- I have searched existing issues and confirmed this is not a duplicate.
- I am on the latest released version, or I have explained above why an
older version is relevant. - I have included a minimal reproduction that I have actually run myself.
- If I used an LLM to draft this issue, I have read and verified every
claim and am willing to defend them in follow-up.
Activity
fix: find core and extended properties through the root relationships (…
fix: find core and extended properties through the root relationships (…