abhigyanpatwari/GitNexus · error · OSError

short write while neutralizing {name}

Error message

short write while neutralizing {name}

What it means

Write-failure guard in _replace_control_file. While overwriting .gitnexusrc or .gitnexusignore, os.write is called in a loop; if it returns zero or negative (no progress), the harness raises OSError('short write while neutralizing <name>'). Note this is raised as OSError, not SandboxError, and propagates out of the neutralization step. The message names which control file failed.

Source

Thrown at eval/workflow_bench/sanitized_graph.py:126

    try:
        metadata = path.lstat()
    except FileNotFoundError:
        metadata = None
    if metadata is not None:
        if stat.S_ISDIR(metadata.st_mode):
            raise SandboxError(f"target-controlled {name} must not be a directory")
        path.unlink()
    descriptor = os.open(
        path,
        os.O_WRONLY | os.O_CREAT | os.O_EXCL | getattr(os, "O_NOFOLLOW", 0),
        0o600,
    )
    try:
        view = memoryview(payload)
        while view:
            written = os.write(descriptor, view)
            if written <= 0:
                raise OSError(f"short write while neutralizing {name}")
            view = view[written:]
        os.fsync(descriptor)
    finally:
        os.close(descriptor)


def _neutralize_target_index_inputs(root: Path) -> None:
    index = root / ".gitnexus"
    try:
        metadata = index.lstat()
    except FileNotFoundError:
        metadata = None
    if metadata is not None:
        if stat.S_ISLNK(metadata.st_mode) or not stat.S_ISDIR(metadata.st_mode):
            raise SandboxError("target .gitnexus path must be a real directory before graph preparation")
        shutil.rmtree(index)
    _replace_control_file(root, ".gitnexusrc", b"{}\n")
    _replace_control_file(root, ".gitnexusignore", b"")

View on GitHub (pinned to d540b00184)

Solutions

  1. Free disk space on the workspace/temp volume and re-run (df -h and du -sh on the sandbox parent).
  2. Point the runtime parent at a volume with more headroom (the destination_parent passed to the graph builder).
  3. Check dmesg/journalctl for EIO or remount-read-only events; replace the failing disk.
  4. Raise the runner's disk quota if a quota (not capacity) caused ENOSPC.

Example fix

# before: run on a 1 GiB tmpfs that fills up
TMPDIR=/run/user/1000 wfbench run ...
# after: use a larger scratch volume
TMPDIR=/var/tmp/scratch wfbench run ...
Defensive patterns

Strategy: try-catch

Validate before calling

import shutil, os
from pathlib import Path

runtime_parent = Path("/var/tmp/wfbench")
free = shutil.disk_usage(runtime_parent).free
if free < 512 * 1024 * 1024:
    raise SystemExit(f"insufficient disk space at {runtime_parent}: {free} bytes free")

Type guard

import os

def can_write_exhaustively(path: os.PathLike, payload: bytes) -> bool:
    try:
        with open(path, "wb") as fh:
            view = memoryview(payload)
            while view:
                n = os.write(fh.fileno(), view)
                if n <= 0:
                    return False
                view = view[n:]
        return True
    except OSError:
        return False

Try / catch

try:
    _neutralize_target_index_inputs(clone_root)
except OSError as exc:
    if "short write while neutralizing" in str(exc):
        log.error("disk/IO failure writing control file: %s", exc)
        # free space, fix FS, then re-run the sanitized graph build
    raise

Prevention

When it happens

Trigger: os.write returns <= 0 on a descriptor that is open for writing to a regular file. Real causes: the underlying filesystem is full (ENOSPC), the disk hit I/O errors (EIO), the FS was remounted read-only mid-write, or a quota was exceeded.

Common situations: Benchmark runs on a small tmpfs that filled up; a CI runner with a low disk quota; a flaky networked filesystem; the workspace disk hit an I/O error.

Related errors


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