abhigyanpatwari/GitNexus · critical · SandboxError

sandbox_copy target cannot traverse a symlink: {parent}

Error message

sandbox_copy target cannot traverse a symlink: {parent}

What it means

_open_publish_parent creates or opens each parent component of the publish destination and refuses to cross a symlink. Unlike the read-only _preflight_exact_root, this is the creation path — it must not follow a symlink when opening the directory that will receive the atomic rename.

Source

Thrown at eval/workflow_bench/task_assets.py:733

                raise SandboxError(f"sandbox_copy target parent has an unsupported type: {relative}")
            next_descriptor = os.open(part, flags, dir_fd=current)
            os.close(current)
            current = next_descriptor
    finally:
        os.close(current)


def _open_publish_parent(clone: Path, parent: PurePosixPath) -> int:
    flags = os.O_RDONLY | os.O_DIRECTORY | getattr(os, "O_CLOEXEC", 0) | getattr(os, "O_NOFOLLOW", 0)
    current = os.open(clone, flags)
    try:
        for part in parent.parts:
            try:
                mode = os.stat(part, dir_fd=current, follow_symlinks=False).st_mode
            except FileNotFoundError:
                mode = None
            if mode is not None and stat.S_ISLNK(mode):
                raise SandboxError(f"sandbox_copy target cannot traverse a symlink: {parent}")
            if mode is not None and not stat.S_ISDIR(mode):
                if not stat.S_ISREG(mode):
                    raise SandboxError(f"sandbox_copy target parent has an unsupported type: {parent}")
                os.unlink(part, dir_fd=current)
                mode = None
            if mode is None:
                os.mkdir(part, mode=0o700, dir_fd=current)
            next_descriptor = os.open(part, flags, dir_fd=current)
            os.close(current)
            current = next_descriptor
        return current
    except BaseException:
        os.close(current)
        raise


def _open_existing_parent(root: Path, parent: PurePosixPath) -> int:
    flags = os.O_RDONLY | os.O_DIRECTORY | getattr(os, "O_CLOEXEC", 0) | getattr(os, "O_NOFOLLOW", 0)

View on GitHub (pinned to d540b00184)

Solutions

  1. Quiesce concurrent writers during the entire materialize call
  2. Remove the symlink at the reported parent path
  3. Use a private clone per run so no cross-process mutation can occur
Defensive patterns

Strategy: try-catch

Try / catch

from eval.workflow_bench.proposer_sandbox import SandboxError

try:
    snapshot.materialize(clone)
except SandboxError as exc:
    if "cannot traverse a symlink" in str(exc):
        raise SystemExit(f"symlink appeared on a parent path during publish; isolate the clone: {exc}") from exc
    raise

Prevention

When it happens

Trigger: A symlink appears at an intermediate parent component in the clone during the publish phase (between preflight and publish, or on a path preflight did not cover); a concurrent mutator planted it.

Common situations: Concurrent mutator sharing the clone; a clone shared with another process between preflight and publish.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12). Data as JSON: /api/errors/61592cc6fe293a1f. Report an issue: GitHub.