abhigyanpatwari/GitNexus · error · ManagedProcessError
managed command failed ({result.state}, exit={result.returnc
Error message
managed command failed ({result.state}, exit={result.returncode}): {result.detail or result.stderr_tail[-1000:]} What it means
Thrown by the _sandbox_git helper (runner_artifacts.py:358) whenever a git invocation run inside the sandbox exits non-zero. It wraps the failure in a ManagedProcessError carrying the command, the process state, the return code, and up to the last 1000 bytes of stderr. _sandbox_git backs the untracked-staging step (`git add --intent-to-add -A`) and the diff-churn shortstat query, so this surfaces any git failure in those paths.
Source
Thrown at eval/workflow_bench/runner_artifacts.py:366
def parse_shortstat(text: str) -> dict[str, int]:
"""Parse `git diff --shortstat` output into churn counters."""
keys = {
"file": "diff_files",
"insertion": "diff_insertions",
"deletion": "diff_deletions",
}
out = dict.fromkeys(keys.values(), 0)
for count, word in re.findall(r"(\d+) (file|insertion|deletion)", text):
out[keys[word]] = int(count)
return out
def _sandbox_git(sandbox: SandboxSession, args: list[str], *, timeout: int = 60) -> str:
command = ["/usr/bin/git", "-c", "core.fsmonitor=false", *args]
result = sandbox.run(command, timeout=timeout, env=build_sandbox_environment())
if not result.ok:
raise ManagedProcessError(command, result)
return result.stdout_tail
def _prepare_untracked_for_diff(sandbox: SandboxSession) -> None:
_sandbox_git(sandbox, ["add", "--intent-to-add", "-A"])
def implementation_diff_digest(
sandbox: SandboxSession,
orig_sha: str,
*,
prepare_untracked: bool = True,
) -> str:
"""Digest non-plan final work entirely inside the containment boundary."""
if not re.fullmatch(r"[0-9a-fA-F]{40,64}", orig_sha):
raise ValueError(f"unsafe git object id: {orig_sha!r}")
if prepare_untracked:View on GitHub (pinned to d540b00184)
Solutions
- Read result.stderr_tail in the raised ManagedProcessError — git's own message identifies the cause (lock, corrupt object, permission).
- Remove a stale .git/index.lock if no git process is actually running.
- Free disk/inode space on the worktree volume.
- Confirm the sandbox environment (build_sandbox_environment) grants write access to the workspace.
- If transient (lock race), retrying the arm after confirming no git process is live usually succeeds.
Example fix
// before — calling _sandbox_git while another git op holds the lock
_sandbox_git(sandbox, ['add','--intent-to-add','-A']) # index.lock -> fails
// after — ensure no other git writer, then retry
import time, os
lock = worktree / '.git' / 'index.lock'
if lock.exists() and no_git_running():
lock.unlink()
_sandbox_git(sandbox, ['add','--intent-to-add','-A']) Defensive patterns
Strategy: try-catch
Validate before calling
from pathlib import Path
def sandbox_git_ready(worktree: Path) -> bool:
lock = worktree / '.git' / 'index.lock'
return not lock.exists() Type guard
null
Try / catch
from eval.workflow_bench.process_control import ManagedProcessError
try:
_sandbox_git(sandbox, ['add', '--intent-to-add', '-A'])
except ManagedProcessError as e:
if 'index.lock' in (e.result.stderr_tail or ''):
# stale or contended lock; clear only if no git process is live
...
raise Prevention
- Always inspect ManagedProcessError.result.stderr_tail first; git names the cause.
- Remove stale .git/index.lock only after confirming no git process is running.
- Ensure the sandbox environment grants write access to the workspace.
- Free disk/inodes on the worktree volume before benchmark runs.
When it happens
Trigger: sandbox.run(['/usr/bin/git','-c','core.fsmonitor=false', *args], ...).ok is False — the sandboxed git subcommand returned a non-zero exit (or was killed/timed out, in which case state != 'exited').
Common situations: A lock contention (.git/index.lock held by another process); a corrupt index; an out-of-disk condition; the sandbox lacks write permission to the worktree; the orig_sha passed to diff does not exist; fsmonitor hook misconfigured (mitigated by core.fsmonitor=false but other config can still bite).
Related errors
- sandboxed git diff did not produce a SHA-256 digest
- {label} is unavailable: {path}: {exc}
- {label} must be a real non-symlink directory: {path}
- {label} contains an unsafe path component: {relative}
- {label} is unreadable: {path}: {exc}
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/03c9067075ce3d21.
Report an issue: GitHub.