{"record":{"id":"8ec2a6bba7e4611c","repo":"abhigyanpatwari/GitNexus","slug":"duplicate-overlay-destination-target","errorCode":null,"errorMessage":"duplicate overlay destination: {target}","messagePattern":"duplicate overlay destination: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/promotion_apply.py","lineNumber":451,"sourceCode":"    if error in {errno.ENOSYS, errno.EINVAL, errno.EOPNOTSUPP}:\n        raise RuntimeError(\"atomic overlay exchange is unavailable on this filesystem\")\n    raise OSError(error, os.strerror(error), f\"{left} <-> {right}\")\n\n\ndef _prepare_targets(\n    payload: list[tuple[PurePosixPath, bytes]],\n    repo_root: Path,\n) -> tuple[Path, int, list[dict[str, Any]]]:\n    \"\"\"Resolve and snapshot every canonical/shipped destination exactly once.\"\"\"\n\n    root, root_descriptor = _open_repository_root(repo_root)\n    prepared: list[dict[str, Any]] = []\n    seen: set[PurePosixPath] = set()\n    try:\n        for relative, content in payload:\n            for target in mirror_targets(relative):\n                if target in seen:\n                    raise ValueError(f\"duplicate overlay destination: {target}\")\n                seen.add(target)\n                parent_descriptor = _open_target_parent(root_descriptor, target)\n                try:\n                    original, mode = _read_destination_at(\n                        parent_descriptor,\n                        target.name,\n                        target=target,\n                    )\n                except BaseException:\n                    os.close(parent_descriptor)\n                    raise\n                prepared.append(\n                    {\n                        \"target\": target,\n                        \"destination\": root / target,\n                        \"parent_path\": root / target.parent,\n                        \"parent_descriptor\": parent_descriptor,\n                        \"name\": target.name,","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/promotion_apply.py#L433-L469","documentation":"Thrown in `_prepare_targets` when two entries in the overlay payload map to the same canonical/shipped target path. `mirror_targets(relative)` is expanded for every `(relative, content)` pair and the set `seen` rejects the second occurrence, so the overlay's own content produces an ambiguous destination.","triggerScenarios":"The overlay file declares two canonical paths whose `mirror_targets()` expansion collides (e.g. the same path shipped twice, or a path and its mirror alias resolving to the same target). Reproducible by calling `apply_promoted_overlay()` or `destination_base_digests()` with such an overlay.","commonSituations":"Editing an overlay manifest to add a path without removing its old alias; a `mirror_targets` rule that maps both a path and a sibling to the same target; renaming a file but leaving the old entry; merging two overlays whose targets overlap.","solutions":["Inspect the offending target printed in the message and search the overlay payload for entries whose `mirror_targets()` yields it.","Run `candidate_overlay_payload(overlay)` and print `[t for rel, _ in payload for t in mirror_targets(rel)]` to find duplicates before calling apply.","Remove the duplicate entry from the overlay, or fix the `mirror_targets` mapping that creates the collision.","Add a unit test that asserts the deduplicated target set equals the raw target list."],"exampleFix":"# diagnostic\nfrom workflow_bench.promotion_apply import candidate_overlay_payload, mirror_targets\nfrom collections import Counter\n_, payload = candidate_overlay_payload(overlay)\ntargets = [str(t) for rel, _ in payload for t in mirror_targets(rel)]\nprint([t for t, c in Counter(targets).items() if c > 1])  # remove these from the overlay","handlingStrategy":"validation","validationCode":"from collections import Counter\nfrom pathlib import PurePosixPath\nfrom workflow_bench.promotion_apply import candidate_overlay_payload, mirror_targets\n\ndef overlay_targets_are_unique(overlay) -> bool:\n    _, payload = candidate_overlay_payload(overlay)\n    targets = [str(t) for rel, _ in payload for t in mirror_targets(rel)]\n    dupes = [t for t, c in Counter(targets).items() if c > 1]\n    if dupes:\n        print(\"duplicate targets:\", dupes)\n        return False\n    return True","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always call `overlay_targets_are_unique(overlay)` before apply or base-digest capture.","Treat the overlay manifest as immutable once digests are recorded; rebuild it from a single source of truth.","Unit-test `mirror_targets` for the paths you ship so no two canonical paths map to the same target."],"tags":["validation","overlay","duplicate","input-error"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}