{"record":{"id":"034f2464eb60e840","repo":"anthropics/skills","slug":"relationship-target-resolves-to-nothing-target-r","errorCode":null,"errorMessage":"relationship target resolves to nothing: {target!r}","messagePattern":"relationship target resolves to nothing: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/docx/scripts/office/helpers/__init__.py","lineNumber":54,"sourceCode":"\n    if target.startswith(\"/\"):\n        joined = target.lstrip(\"/\")\n    else:\n        joined = posixpath.join(posixpath.dirname(source_part), target)\n\n    parts: list[str] = []\n    for segment in posixpath.normpath(joined).split(\"/\"):\n        if segment in (\"\", \".\"):\n            continue\n        if segment == \"..\":\n            if not parts:\n                raise ValueError(f\"relationship target escapes the package: {target!r}\")\n            parts.pop()\n        else:\n            parts.append(segment)\n\n    if not parts:\n        raise ValueError(f\"relationship target resolves to nothing: {target!r}\")\n    return \"/\".join(parts)\n\n\ndef rels_source_part(rels_file: Path, unpacked_dir: Path) -> str:\n    owner_dir = rels_file.parent.parent.relative_to(unpacked_dir)\n    return posixpath.join(owner_dir.as_posix(), rels_file.name[: -len(\".rels\")]).lstrip(\"./\")\n\n\ndef part_text(data: bytes) -> str:\n    return data.decode(\"utf-8\", \"surrogateescape\")\n\n\nXML_SPACE = \" \\t\\r\\n\"\n\n\ndef rendered_text(text: str, preserve: bool) -> str:\n    return text if preserve else text.strip(XML_SPACE)\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/anthropics/skills/blob/f6656c1256d5a8adfa37db9110046ef20bac644c/skills/docx/scripts/office/helpers/__init__.py#L36-L72","documentation":"opc_target() raises this when a non-empty relationship target normalizes to an empty part name — every segment was '.', empty, or consumed by '..' pops (e.g. Target='.', Target='./', or 'a/..'). OPC requires each relationship to name a real part; an empty resolution means the .rels entry is corrupt. Exists in both the docx and pptx copies of office/helpers/__init__.py.","triggerScenarios":"A Relationship element with Target=\".\", Target=\"./\", or a target that self-cancels like \"word/document.xml/..\"; occurs while scanning any .rels file during unpack-based operations (thumbnails, cleaning, comment insertion).","commonSituations":"Hand-edited or machine-generated .rels with placeholder targets; tools that write Target=\"\" variants for relationships they mean to delete; round-tripped files from buggy serializers.","solutions":["Find the Relationship whose target is '.' or './' (the message shows it) and point it at the intended part, or remove the dead relationship entry entirely.","If the relationship is vestigial (e.g. an external link wrongly marked internal), delete the <Relationship> element from the .rels file.","Re-save through PowerPoint/LibreOffice to let a conformant writer rebuild the .rels files.","Validate the package with an OOXML validator before feeding it to these scripts."],"exampleFix":"<!-- before -->\n<Relationship Id=\"rId5\" Type=\".../customXml\" Target=\".\"/>\n\n<!-- after: remove or point at a real part -->\n<!-- <Relationship ... /> deleted -->","handlingStrategy":"validation","validationCode":"import posixpath\n\ndef target_resolves_to_part(target: str, source_part: str) -> bool:\n    if not target:\n        return False\n    joined = posixpath.normpath(posixpath.join(posixpath.dirname(source_part), target)) if not target.startswith(\"/\") else posixpath.normpath(target.lstrip(\"/\"))\n    return joined not in (\"\", \".\")","typeGuard":null,"tryCatchPattern":"try:\n    opc_target(target, source_part, target_mode)\nexcept ValueError as e:\n    if \"resolves to nothing\" in str(e):\n        drop_relationship()  # dead entry; remove from .rels rather than guess\n    else:\n        raise","preventionTips":["Never write placeholder targets like '.' or './' into .rels files.","Remove relationships you intend to delete instead of blanking their Target.","Validate generated packages with an OOXML validator before shipping."],"tags":["ooxml","opc","relationships","validation","docx","pptx"],"backgroundTag":null,"analyzedSha":"f6656c1256d5a8adfa37db9110046ef20bac644c","analyzedAt":"2026-08-14T16:09:17.493Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}