anthropics/skills · error · RefusedToClean
no relationship in this package names a part we can resolve.
Error message
no relationship in this package names a part we can resolve. Refusing to treat every file as unreferenced.
What it means
clean_unused_files() guards against catastrophic deletion: if the package contains .rels files but get_referenced_files() resolves none of them to actual parts, every file would look 'unreferenced' and a naive cleaner would delete the whole package. It raises RefusedToClean instead, treating total resolution failure as a parse/corruption problem rather than an unreferenced-file problem.
Source
Thrown at skills/pptx/scripts/clean.py:257
changed = False
for override in list(dom.getElementsByTagName("Override")):
part_name = override.getAttribute("PartName").lstrip("/")
if part_name in removed_files:
if override.parentNode:
override.parentNode.removeChild(override)
changed = True
if changed:
with open(ct_path, "wb") as f:
f.write(dom.toxml(encoding="utf-8"))
def clean_unused_files(unpacked_dir: Path) -> list[str]:
all_removed = []
if list(unpacked_dir.rglob("*.rels")) and not get_referenced_files(unpacked_dir):
raise RefusedToClean(
"no relationship in this package names a part we can resolve. "
"Refusing to treat every file as unreferenced."
)
slides_removed = remove_orphaned_slides(unpacked_dir)
all_removed.extend(slides_removed)
trash_removed = remove_trash_directory(unpacked_dir)
all_removed.extend(trash_removed)
while True:
removed_rels = remove_orphaned_rels_files(unpacked_dir)
referenced = get_referenced_files(unpacked_dir)
removed_files = remove_orphaned_files(unpacked_dir, referenced)
total_removed = removed_rels + removed_files
if not total_removed:
breakView on GitHub (pinned to f6656c1256)
Solutions
- Re-save the deck with PowerPoint or LibreOffice ('soffice --headless --convert-to pptx') to rebuild conformant relationships, then retry.
- Inspect the .rels files for backslash targets or traversal targets (fix per errors 14/15/16) and repair them.
- Re-unpack the original pptx completely and confirm no parts are missing on disk.
- Run a package validator to find which relationships fail to resolve.
Example fix
# before
clean_unused_files(unpacked_dir) # RefusedToClean: nothing resolvable
# after
import subprocess, zipfile, tempfile
with tempfile.TemporaryDirectory() as td:
subprocess.run(["soffice", "--headless", "--convert-to", "pptx", "--outdir", td, str(src)], check=True)
with zipfile.ZipFile(next(Path(td).glob("*.pptx"))) as zf:
zf.extractall(unpacked_dir_unpacked)
clean_unused_files(unpacked_dir_unpacked) Defensive patterns
Strategy: try-catch
Validate before calling
import zipfile
def package_has_resolvable_rels(path: str) -> bool:
# cheap smoke check: every internal rel target should at least exist as a part
import re, posixpath
with zipfile.ZipFile(path) as zf:
names = set(zf.namelist())
for name in [n for n in names if n.endswith(".rels")]:
base = posixpath.dirname(posixpath.dirname(name))
for m in re.finditer(rb'Target="([^"]+)"[^>]*?(TargetMode="External")?', zf.read(name)):
t = m.group(1).decode()
if m.group(2) or "://" in t or t.startswith("/"):
continue
if posixpath.normpath(posixpath.join(base, t)) not in names:
return False
return True Try / catch
try:
removed = clean_unused_files(unpacked_dir)
except RefusedToClean as e:
log.warning("package %s not cleaned (unresolvable relationships): %s", src, e)
# keep original untouched; re-save via LibreOffice and retry once, else skip Prevention
- Treat RefusedToClean as a stop signal — never work around it by forcing deletion.
- Normalize decks through a conformant re-save before cleaning pipelines.
- Validate that .rels targets resolve to existing parts before cleanup jobs.
- Operate on copies; preserve originals for destructive operations.
When it happens
Trigger: Cleaning a pptx where all relationship targets fail resolution — e.g. every target contains backslashes or escapes the package (triggering opc_target failures that are swallowed per-entry), targets point at parts that do not exist on disk, or the unpacked tree is missing files that the rels reference.
Common situations: Corrupt or non-conformant decks from converters (Windows-style rels targets); partially extracted archives where some parts failed to unpack; hand-modified packages; the same root causes as errors 14-16 surfacing at the clean orchestration layer.
Related errors
- <p:sldIdLst> lists {len(listed)} slide(s) and none of the {l
- relationship target is not a POSIX part name: {target!r}
- relationship target escapes the package: {target!r}
- relationship target resolves to nothing: {target!r}
- relationship target is not a POSIX part name: {target!r}
AI-assisted analysis of anthropics/skills@f6656c1256 (2026-08-14).
Data as JSON: /api/errors/4410d60e32927a5a.
Report an issue: GitHub.