{"record":{"id":"0acf1ec4ffe25497","repo":"abhigyanpatwari/GitNexus","slug":"candidate-destination-parent-must-be-a-real-direct","errorCode":null,"errorMessage":"candidate destination parent must be a real directory: {relative.parent}: {exc}","messagePattern":"candidate destination parent must be a real directory: (.+?): (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/evolution.py","lineNumber":183,"sourceCode":"\ndef _replace_regular_file(root: Path, relative: Path, content: bytes) -> None:\n    \"\"\"Replace a clone file through validated directory descriptors.\"\"\"\n\n    if relative.is_absolute() or not relative.parts or \"..\" in relative.parts:\n        raise ValueError(f\"candidate destination escapes the clone: {relative}\")\n    _require_real_directory(root, label=\"candidate destination root\")\n    directory_flags = os.O_RDONLY | getattr(os, \"O_DIRECTORY\", 0) | getattr(os, \"O_NOFOLLOW\", 0)\n    descriptor = os.open(root, directory_flags)\n    try:\n        for part in relative.parts[:-1]:\n            try:\n                os.mkdir(part, mode=0o700, dir_fd=descriptor)\n            except FileExistsError:\n                pass\n            try:\n                child = os.open(part, directory_flags, dir_fd=descriptor)\n            except OSError as exc:\n                raise ValueError(\n                    f\"candidate destination parent must be a real directory: {relative.parent}: {exc}\"\n                ) from exc\n            os.close(descriptor)\n            descriptor = child\n\n        leaf = relative.name\n        try:\n            existing = os.stat(leaf, dir_fd=descriptor, follow_symlinks=False)\n        except FileNotFoundError:\n            existing = None\n        except OSError as exc:\n            raise ValueError(f\"candidate destination is unreadable: {relative}: {exc}\") from exc\n        if existing is not None and (stat.S_ISLNK(existing.st_mode) or not stat.S_ISREG(existing.st_mode)):\n            raise ValueError(f\"candidate destination must be a regular non-symlink file: {relative}\")\n\n        temporary = f\".wfbench-overlay-{secrets.token_hex(12)}\"\n        temp_descriptor = os.open(\n            temporary,","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/evolution.py#L165-L201","documentation":"Thrown by _replace_regular_file (evolution.py:183) while walking the intermediate parent components of the destination with directory file descriptors using O_RDONLY|O_DIRECTORY|O_NOFOLLOW. Each parent part is mkdir'd (0o700, FileExistsError ignored) then re-opened; if os.open of a part fails with any OSError, the parent is not a real directory — it is a symlink, a regular file, or unreadable.","triggerScenarios":"An intermediate path component in the clone is a symlink or regular file instead of a directory (e.g. .claude is a file); the clone lacks write permission to mkdir the missing parent; an existing parent has mode bits that block open.","commonSituations":"The clone already contains a file named '.claude' or 'skills' where a directory is expected; clone was partially reset or left in a broken state; running as a user without write permission on the clone root.","solutions":["Inspect the clone at the named {relative.parent}: remove any symlink/file blocking the directory chain.","Ensure the clone root and .claude/skills path are writable so missing parents can be created (mode 0o700).","Reset the clone to a clean checkout and re-apply the overlay."],"exampleFix":"# before: a file blocks the directory chain in the clone\nclone/.claude   # is a regular file, not a dir -> parent not a real directory\n\n# after: ensure real directories exist\nfrom pathlib import Path\nfor d in [Path('clone/.claude'), Path('clone/.claude/skills')]:\n    if d.exists() and not d.is_dir():\n        d.unlink()\n    d.mkdir(parents=True, exist_ok=True)","handlingStrategy":"validation","validationCode":"import os, stat\nfrom pathlib import Path\n\ndef clone_parents_are_real_dirs(clone: Path, rel: Path) -> bool:\n    cur = clone\n    for part in rel.parts[:-1]:\n        cur = cur / part\n        try:\n            m = cur.lstat().st_mode\n        except FileNotFoundError:\n            continue\n        if stat.S_ISLNK(m) or not stat.S_ISDIR(m):\n            return False\n    return True","typeGuard":"null","tryCatchPattern":"try:\n    apply_candidate_overlay(overlay, worktree, sandbox=sandbox)\nexcept ValueError as exc:\n    if 'parent must be a real directory' in str(exc):\n        # inspect and repair the named parent path in the clone\n        ...","preventionTips":["Start from a clean clone so .claude/skills are real directories.","Ensure the harness user has write permission to create missing parents.","Never symlink .claude or skills directories in the clone."],"tags":["filesystem","overlay","clone","sandbox"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}