abhigyanpatwari/GitNexus · error · SandboxError

task asset snapshot contains a special directory: {path}

Error message

task asset snapshot contains a special directory: {path}

What it means

Raised by _freeze_snapshot during the directories walk when an entry listed as a directory is neither a symlink nor an actual directory (stat.S_ISDIR false). It is the directory-walk analogue of the 626 regular-file check: a non-directory, non-symlink entry in a directory slot is treated as a special file and rejected.

Source

Thrown at eval/workflow_bench/task_assets.py:1007

            mode = path.lstat().st_mode
            relative = path.relative_to(root)
            if stat.S_ISLNK(mode):
                if not relative.parts or relative.parts[0] != "dependencies":
                    raise SandboxError(f"task asset snapshot contains an unexpected symlink: {path}")
                continue
            if not stat.S_ISREG(mode):
                raise SandboxError(f"task asset snapshot contains a special file: {path}")
            path.chmod(0o400 | (0o100 if stat.S_IMODE(mode) & 0o111 else 0))
        for name in directories:
            path = Path(current) / name
            mode = path.lstat().st_mode
            relative = path.relative_to(root)
            if stat.S_ISLNK(mode):
                if not relative.parts or relative.parts[0] != "dependencies":
                    raise SandboxError(f"task asset snapshot contains an unexpected symlink: {path}")
                continue
            if not stat.S_ISDIR(mode):
                raise SandboxError(f"task asset snapshot contains a special directory: {path}")
            path.chmod(0o500)
        Path(current).chmod(0o500)


def _thaw_tree(root: Path) -> None:
    for current, directories, files in os.walk(root, topdown=True, followlinks=False):
        Path(current).chmod(0o700)
        for name in directories:
            path = Path(current) / name
            if not path.is_symlink():
                path.chmod(0o700)
        for name in files:
            path = Path(current) / name
            if not path.is_symlink():
                path.chmod(0o600)


def capture_task_dependency_binding(

View on GitHub (pinned to d540b00184)

Solutions

  1. Make the snapshot root quiescent during _freeze_snapshot (no concurrent writes/replaces), then re-prepare.
  2. Remove the offending non-directory entry from the captured tree.
  3. If the filesystem misreports types, capture from a stable local filesystem (ext4/xfs) instead of a network/9p mount.
Defensive patterns

Strategy: validation

Validate before calling

import os, stat
from pathlib import Path

def assert_only_real_dirs(root: Path) -> None:
    for current, dirs, _ in os.walk(root, followlinks=False):
        for name in dirs:
            mode = (Path(current) / name).lstat().st_mode
            if not (stat.S_ISDIR(mode) or stat.S_ISLNK(mode)):
                raise ValueError(f'non-directory in dir slot would be rejected by freeze: {Path(current)/name}')

# Run against a quiescent tree (no concurrent writes) before cache.prepare.

Prevention

When it happens

Trigger: Extremely rare: os.walk reports an entry under directories whose lstat mode is neither S_ISDIR nor S_ISLNK. Can happen with a FIFO/socket/device whose name happened to be classified as a directory by walk, on filesystems with unusual type reporting, or when an entry is racily replaced between the readdir and the lstat.

Common situations: TOCTOU between os.walk's readdir and the per-entry lstat (entry replaced mid-walk); exotic filesystems (some network/9p mounts) that misreport entry types; a corrupted index entry.

Related errors


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