{"record":{"id":"7ceade571192fe25","repo":"abhigyanpatwari/GitNexus","slug":"atomic-overlay-exchange-is-unavailable-on-this-fil","errorCode":null,"errorMessage":"atomic overlay exchange is unavailable on this filesystem","messagePattern":"atomic overlay exchange is unavailable on this filesystem","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"eval/workflow_bench/promotion_apply.py","lineNumber":434,"sourceCode":"    except AttributeError as exc:\n        raise RuntimeError(\"atomic overlay exchange is unavailable on this platform\") from exc\n    renameat2.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint]\n    renameat2.restype = ctypes.c_int\n    if (\n        renameat2(\n            parent_descriptor,\n            os.fsencode(left),\n            parent_descriptor,\n            os.fsencode(right),\n            _RENAME_EXCHANGE,\n        )\n        == 0\n    ):\n        os.fsync(parent_descriptor)\n        return\n    error = ctypes.get_errno()\n    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)","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/promotion_apply.py#L416-L452","documentation":"Thrown by `_exchange_at` when `renameat2` was found in libc but the actual syscall returned non-zero with errno `ENOSYS`, `EINVAL`, or `EOPNOTSUPP`. The kernel or the filesystem backing the directory does not support `RENAME_EXCHANGE`, so the atomic swap cannot be honored even though the platform looked capable.","triggerScenarios":"Calling `apply_promoted_overlay` against a directory on overlayfs (common in Docker/OCI builds), network filesystems (NFS/CIFS/9p), certain FUSE filesystems, a kernel older than 3.15 that exposes the symbol but returns `ENOSYS`, or a filesystem that rejects `RENAME_EXCHANGE` with `EOPNOTSUPP`/`EINVAL`. The guard at promotion_apply.py:433 specifically classifies these three errnos as the filesystem-unsupported case.","commonSituations":"Builds inside Docker with overlay2 storage driver writing into a bind-mounted directory; Kubernetes pods on 9p or a virtualized FS; CI on a Linux kernel that lacks `CONFIG_RENAME_EXCHANGE`-equivalent support; exotic FUSE mounts. Different from error 400 — here the symbol exists but the call degrades.","solutions":["Move the repo_root onto a filesystem that supports RENAME_EXCHANGE — ext4, xfs, btrfs on a modern Linux kernel (>= 3.15).","If in Docker, run the publish step with `--storage-driver=vfs` or write to a tmpfs/ext4 volume mounted into the container rather than the overlay root.","Verify support directly: call `renameat2` on the exact target parent dir from a small Python probe and inspect errno; reproduce the exact directory + filesystem the bench uses.","Avoid bind-mounting the repo over a network FS for the apply step; keep it on local disk."],"exampleFix":"# before: repo_root lives on overlayfs (Docker default)\napply_promoted_overlay(overlay, repo_root=Path('/app/repo'))  # -> RuntimeError\n# after: bind an ext4 volume\n#   docker run -v /tmp/repo:/repo --tmpfs /tmp ...\napply_promoted_overlay(overlay, repo_root=Path('/repo'))","handlingStrategy":"validation","validationCode":"import ctypes, errno, os, tempfile\n\ndef filesystem_supports_rename_exchange(directory: str) -> bool:\n    \"\"\"Probe RENAME_EXCHANGE on the exact FS that backs `directory`.\"\"\"\n    try:\n        libc = ctypes.CDLL(None, use_errno=True)\n        libc.renameat2.argtypes = [ctypes.c_int, ctypes.c_char_p, ctypes.c_int, ctypes.c_char_p, ctypes.c_uint]\n        libc.renameat2.restype = ctypes.c_int\n    except AttributeError:\n        return False\n    d = tempfile.mkdtemp(dir=directory)\n    a = os.path.join(d, \"a\"); b = os.path.join(d, \"b\")\n    open(a, \"w\").write(\"a\"); open(b, \"w\").write(\"b\")\n    fd = os.open(d, os.O_RDONLY)\n    rc = libc.renameat2(fd, b\"a\", fd, b\"b\", 2)  # RENAME_EXCHANGE\n    err = ctypes.get_errno()\n    os.close(fd); os.remove(a); os.remove(b); os.rmdir(d)\n    if rc == 0:\n        return True\n    return err not in {errno.ENOSYS, errno.EINVAL, errno.EOPNOTSUPP}","typeGuard":"null","tryCatchPattern":"from workflow_bench.promotion_apply import apply_promoted_overlay\n\ntry:\n    apply_promoted_overlay(overlay, expected_target_bases=bases)\nexcept RuntimeError as exc:\n    if \"unavailable on this filesystem\" in str(exc):\n        # move repo_root to ext4/xfs/btrfs, or switch Docker storage driver\n        ...\n    raise","preventionTips":["Probe the exact target directory's filesystem before apply (different FS, different answer).","Keep `repo_root` on ext4/xfs/btrfs; avoid overlayfs-backed bind mounts in Docker for the publish step.","Treat ENOSYS/EINVAL/EOPNOTSUPP from renameat2 as a hard platform stop, not a retryable error."],"tags":["filesystem","overlayfs","renameat2","docker","errno"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}