abhigyanpatwari/GitNexus · error · SandboxError

dependency symlink target exceeds the path limit: {relative}

Error message

dependency symlink target exceeds the path limit: {relative}

What it means

Raised by _copy_symlink when the symlink target, encoded as UTF-8 bytes, exceeds MAX_TASK_ASSET_PATH_BYTES (4096 bytes). This mirrors the path-length guard applied to manifest paths generally and keeps individual entries bounded so the manifest cannot be bloated by a single pathological link. It is a containment limit, not an expected-size assertion.

Source

Thrown at eval/workflow_bench/task_assets.py:476

            )
        )

    def _copy_symlink(
        self,
        parent_descriptor: int,
        name: str,
        relative: PurePosixPath,
        before: os.stat_result,
    ) -> None:
        try:
            target = os.readlink(name, dir_fd=parent_descriptor)
            target_bytes = target.encode("utf-8")
        except (OSError, UnicodeEncodeError) as exc:
            raise SandboxError(f"dependency symlink is unreadable or not UTF-8: {relative}") from exc
        if not target or PurePosixPath(target).is_absolute() or "\x00" in target:
            raise SandboxError(f"dependency symlink must be a bounded relative link: {relative}")
        if len(target_bytes) > MAX_TASK_ASSET_PATH_BYTES:
            raise SandboxError(f"dependency symlink target exceeds the path limit: {relative}")
        if self.budget.total_bytes + len(target_bytes) > MAX_TASK_ASSET_BYTES:
            raise SandboxError("sandbox_copy exceeds the total byte limit")
        destination = self.destination / Path(*relative.parts)
        os.symlink(target, destination)
        after = os.stat(name, dir_fd=parent_descriptor, follow_symlinks=False)
        if (
            _mutation_identity(before) != _mutation_identity(after)
            or os.readlink(
                name,
                dir_fd=parent_descriptor,
            )
            != target
        ):
            raise SandboxError(f"dependency symlink changed while snapshotting: {relative}")
        self.total_bytes += len(target_bytes)
        self.budget.total_bytes += len(target_bytes)
        self._record(
            AssetManifestEntry(

View on GitHub (pinned to d540b00184)

Solutions

  1. Locate the link: `find <dep-source> -type l -exec sh -c 't=$(readlink "$1"); [ ${#t} -gt 4096 ] && echo "$1: ${#t} bytes"' _ {} \;`.
  2. Recreate the link with a shorter relative target, or replace it with a directory if a long alias was being used to mirror a path.
  3. Remove the offending link if it is not needed for the dependency to function.
  4. Regenerate node_modules with a standard package manager rather than a custom linking script that produces long targets.

Example fix

# before — link target over 4096 bytes
ln -s "$(printf 'a%.0s' {1..5000})" node_modules/.long

# after
rm node_modules/.long
ln -s ../real-package node_modules/.long
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
import os

MAX_PATH_BYTES = 4096

def validate_symlink_target_length(dep_source: Path) -> None:
    for current, dirs, files in os.walk(dep_source, followlinks=False):
        for name in dirs + files:
            p = Path(current) / name
            if p.is_symlink():
                n = len(os.readlink(p).encode("utf-8"))
                if n > MAX_PATH_BYTES:
                    raise ValueError(f"symlink target too long ({n} bytes): {p}")

for d in task.get("sandbox_dependencies", []):
    validate_symlink_target_length(repo_path / d["source"])

Type guard

import os
from pathlib import Path

def symlink_target_within_limit(p: Path, limit: int = 4096) -> bool:
    try:
        return len(os.readlink(p).encode("utf-8")) <= limit
    except (OSError, UnicodeEncodeError):
        return False

Try / catch

from eval.workflow_bench.propposer_sandbox import SandboxError

try:
    snapshot = cache.prepare(task, repo=repo, resolved_sha=sha)
except SandboxError as exc:
    if "target exceeds the path limit" in str(exc):
        # shorten or remove the offending link, then re-run
        raise
    raise

Prevention

When it happens

Trigger: A symlink whose target string is longer than 4096 bytes when UTF-8 encoded. Rare in practice; can occur with generated links whose target is a deeply nested or programmatically constructed path, or with malicious/corrupted link targets in a vendored dependency.

Common situations: A vendored package contains an absurdly long symlink target (generated by a buggy installer). A test fixture deliberately created an over-long link. Symlink targets that embed long base64 or URL strings.

Related errors


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