{"record":{"id":"c07178b7966cb9e5","repo":"abhigyanpatwari/GitNexus","slug":"label-target-has-the-wrong-type-relative","errorCode":null,"errorMessage":"{label} target has the wrong type: {relative}","messagePattern":"(.+?) target has the wrong type: (.+?)","errorType":"exception","errorClass":"SandboxError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/proposer_sandbox.py","lineNumber":626,"sourceCode":"            mode = os.stat(leaf, dir_fd=current_fd, follow_symlinks=False).st_mode\n        except FileNotFoundError:\n            mode = None\n        if mode is not None and stat.S_ISLNK(mode):\n            raise SandboxError(f\"{label} target cannot be a symlink: {relative}\")\n        if directory is True:\n            if mode is None:\n                os.mkdir(leaf, mode=0o700, dir_fd=current_fd)\n            elif not stat.S_ISDIR(mode):\n                raise SandboxError(f\"{label} directory target has the wrong type: {relative}\")\n        elif directory is False:\n            if mode is None:\n                file_flags = os.O_WRONLY | os.O_CREAT | os.O_EXCL | nofollow\n                file_fd = os.open(leaf, file_flags, 0o600, dir_fd=current_fd)\n                os.close(file_fd)\n            elif not stat.S_ISREG(mode):\n                raise SandboxError(f\"{label} file target has the wrong type: {relative}\")\n        elif mode is not None and not (stat.S_ISREG(mode) or stat.S_ISDIR(mode)):\n            raise SandboxError(f\"{label} target has the wrong type: {relative}\")\n    finally:\n        os.close(current_fd)\n    return clone / Path(*relative.parts)\n\n\ndef stage_task_assets(\n    task: Mapping[str, Any],\n    *,\n    repo: Path,\n    clone: Path,\n) -> list[ReadOnlyMount]:\n    \"\"\"Compatibility wrapper for immutable task-asset staging.\"\"\"\n\n    # Kept lazy to avoid a module cycle: task_assets uses the sandbox's\n    # shared error, mount, and no-follow target primitives.\n    from .task_assets import stage_task_assets as stage_immutable_task_assets\n\n    return stage_immutable_task_assets(task, repo=repo, clone=clone)","sourceCodeStart":608,"sourceCodeEnd":644,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/proposer_sandbox.py#L608-L644","documentation":"Raised by _prepare_clone_target in the type-agnostic branch (directory=None): the leaf exists and is neither a regular file nor a directory (e.g. a FIFO, socket, character/block device). The harness allows an existing leaf only if it is a plain file or directory; any other node type is rejected because mounting or writing through it is undefined and unsafe.","triggerScenarios":"_prepare_clone_target(..., directory=None) finds an existing leaf whose mode is neither stat.S_ISREG nor stat.S_ISDIR — for example a leftover FIFO/socket/device node at the target path inside the clone.","commonSituations":"A previous test or setup step created a FIFO/socket at the target path (common with test fixtures that mkfifo); a tracked special file occupies the path; a malformed artifact from a crashed run was left behind.","solutions":["Identify the node type: `stat -c '%F' <worktree>/<leaf>`.","Remove the special file from the repo or reroute the target to a clean path.","Recreate the worktree from a clean detached checkout so no stale special nodes persist.","Audit any setup script for mkfifo/socket/device creation at harness-managed paths."],"exampleFix":"// before — a leftover FIFO occupies the target path\ntarget: eval/workflow_bench/run.fifo\n// after — remove the stale special node\nrm <worktree>/eval/workflow_bench/run.fifo   # or git rm if tracked","handlingStrategy":"validation","validationCode":"import os, stat\nfrom pathlib import PurePosixPath\n\ndef leaf_is_file_or_dir_or_absent(clone: Path, relative: str) -> bool:\n    parts = PurePosixPath(relative).parts\n    pfd = os.open(clone, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW)\n    try:\n        for p in parts[:-1]:\n            nxt = os.open(p, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=pfd)\n            os.close(pfd); pfd = nxt\n        try:\n            mode = os.stat(parts[-1], dir_fd=pfd, follow_symlinks=False).st_mode\n            return stat.S_ISREG(mode) or stat.S_ISDIR(mode)\n        except FileNotFoundError:\n            return True\n    finally:\n        os.close(pfd)","typeGuard":null,"tryCatchPattern":"from .proposer_sandbox import SandboxError\n\ntry:\n    target = _prepare_clone_target(clone, PurePosixPath(rel), directory=None, label='target')\nexcept SandboxError:\n    # leaf is a FIFO/socket/device; remove it or reroute\n    raise","preventionTips":["Audit setup scripts for mkfifo/socket/mknod at harness-managed paths.","Use clean worktrees so stale special nodes cannot persist.","Validate leaf node types before staging."],"tags":["sandbox","path-validation","trust-boundary","task-assets"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}