{"record":{"id":"0265458301745664","repo":"abhigyanpatwari/GitNexus","slug":"label-must-be-a-real-directory-lexical-exc","errorCode":null,"errorMessage":"{label} must be a real directory: {lexical}: {exc}","messagePattern":"(.+?) must be a real directory: (.+?): (.+?)","errorType":"exception","errorClass":"SandboxError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/proposer_sandbox.py","lineNumber":549,"sourceCode":"        \"--\",\n        *command,\n    ]\n\n\ndef require_claude_sandbox_helpers() -> None:\n    \"\"\"Fail before paid work when Claude's mandatory inner sandbox cannot run.\"\"\"\n\n    _resolve_executable(None, \"socat\")\n\n\ndef _real_directory(path: Path, *, label: str) -> Path:\n    \"\"\"Return an absolute directory path without accepting any symlink hop.\"\"\"\n\n    lexical = path.expanduser().absolute()\n    try:\n        mode = lexical.lstat().st_mode\n    except OSError as exc:\n        raise SandboxError(f\"{label} must be a real directory: {lexical}: {exc}\") from exc\n    if stat.S_ISLNK(mode) or not stat.S_ISDIR(mode):\n        raise SandboxError(f\"{label} must be a real directory: {lexical}\")\n    try:\n        resolved = lexical.resolve(strict=True)\n    except OSError as exc:\n        raise SandboxError(f\"{label} must be a real directory: {lexical}: {exc}\") from exc\n    if resolved != lexical:\n        raise SandboxError(f\"{label} must not traverse symlinks: {lexical}\")\n    return lexical\n\n\ndef _safe_repo_source(repo: Path, relative: str, *, label: str) -> tuple[Path, Path]:\n    candidate = PurePosixPath(relative)\n    if candidate.is_absolute() or \"..\" in candidate.parts or not candidate.parts:\n        raise SandboxError(f\"{label} must be a repository-relative path: {relative!r}\")\n    lexical = repo / Path(*candidate.parts)\n    resolved = lexical.resolve()\n    try:","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/proposer_sandbox.py#L531-L567","documentation":"Raised by _real_directory when lstat() on the lexical (expanded, absolute) path raises OSError. _real_directory exists to reject any symlink hop and must first stat the path exactly as given; an OSError here (ENOENT, EACCES, ELOOP) means the directory is not even inspectable, so the label-specific message includes the original exception text.","triggerScenarios":"Calling code that funnels a path through _real_directory (mount sources, repo roots, runtime dirs) with a path whose lstat fails: nonexistent path, missing parent, permission denied on a component, too many symlink levels (ELOOP).","commonSituations":"Config points a directory env var at a path that was never created; a mount source directory is created lazily but the preflight ran before creation; CI runs as a user without read on the parent; a path constructed from an unset env var produced a literal like '/'; a symlink loop in the path prefix.","solutions":["Create the directory before validation: path.mkdir(parents=True, exist_ok=True).","Confirm the path is correct (typo, wrong env var) with ls -ld from the same user.","Fix permissions on the parent components so lstat succeeds.","Resolve env vars upstream and fail with a clear config error if unset."],"exampleFix":"// before\nreal = _real_directory(Path(mount_src), label='mount source')  # missing dir\n// after\nmount_src = Path(mount_src)\nmount_src.mkdir(parents=True, exist_ok=True)\nreal = _real_directory(mount_src, label='mount source')","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef ensure_real_dir(p: Path) -> Path:\n    p = p.expanduser().absolute()\n    try:\n        p.lstat()\n    except OSError as exc:\n        raise ValueError(f'cannot stat {p}: {exc}') from exc\n    return p\n\n# call ensure_real_dir before _real_directory to get a clearer error","typeGuard":"null","tryCatchPattern":"try:\n    real = _real_directory(path, label=label)\nexcept SandboxError as exc:\n    if label in str(exc) and 'must be a real directory' in str(exc) and ': ' in str(exc):\n        path.mkdir(parents=True, exist_ok=True)\n        real = _real_directory(path, label=label)\n    raise","preventionTips":["Create required directories during setup before preflight.","Validate env-var-derived paths are non-empty and real.","Fix parent permissions so lstat can traverse.","Resolve config paths to absolute form early."],"tags":["filesystem","symlink","validation","sandbox","security"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}