{"record":{"id":"03c9067075ce3d21","repo":"abhigyanpatwari/GitNexus","slug":"managed-command-failed-result-state-exit-resu-03c906","errorCode":null,"errorMessage":"managed command failed ({result.state}, exit={result.returncode}): {result.detail or result.stderr_tail[-1000:]}","messagePattern":"managed command failed \\((.+?), exit=(.+?)\\): (.+?)","errorType":"exception","errorClass":"ManagedProcessError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/runner_artifacts.py","lineNumber":366,"sourceCode":"def parse_shortstat(text: str) -> dict[str, int]:\n    \"\"\"Parse `git diff --shortstat` output into churn counters.\"\"\"\n\n    keys = {\n        \"file\": \"diff_files\",\n        \"insertion\": \"diff_insertions\",\n        \"deletion\": \"diff_deletions\",\n    }\n    out = dict.fromkeys(keys.values(), 0)\n    for count, word in re.findall(r\"(\\d+) (file|insertion|deletion)\", text):\n        out[keys[word]] = int(count)\n    return out\n\n\ndef _sandbox_git(sandbox: SandboxSession, args: list[str], *, timeout: int = 60) -> str:\n    command = [\"/usr/bin/git\", \"-c\", \"core.fsmonitor=false\", *args]\n    result = sandbox.run(command, timeout=timeout, env=build_sandbox_environment())\n    if not result.ok:\n        raise ManagedProcessError(command, result)\n    return result.stdout_tail\n\n\ndef _prepare_untracked_for_diff(sandbox: SandboxSession) -> None:\n    _sandbox_git(sandbox, [\"add\", \"--intent-to-add\", \"-A\"])\n\n\ndef implementation_diff_digest(\n    sandbox: SandboxSession,\n    orig_sha: str,\n    *,\n    prepare_untracked: bool = True,\n) -> str:\n    \"\"\"Digest non-plan final work entirely inside the containment boundary.\"\"\"\n\n    if not re.fullmatch(r\"[0-9a-fA-F]{40,64}\", orig_sha):\n        raise ValueError(f\"unsafe git object id: {orig_sha!r}\")\n    if prepare_untracked:","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/runner_artifacts.py#L348-L384","documentation":"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.","triggerScenarios":"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').","commonSituations":"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).","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."],"exampleFix":"// before — calling _sandbox_git while another git op holds the lock\n_sandbox_git(sandbox, ['add','--intent-to-add','-A'])  # index.lock -> fails\n\n// after — ensure no other git writer, then retry\nimport time, os\nlock = worktree / '.git' / 'index.lock'\nif lock.exists() and no_git_running():\n    lock.unlink()\n_sandbox_git(sandbox, ['add','--intent-to-add','-A'])","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\n\ndef sandbox_git_ready(worktree: Path) -> bool:\n    lock = worktree / '.git' / 'index.lock'\n    return not lock.exists()","typeGuard":"null","tryCatchPattern":"from eval.workflow_bench.process_control import ManagedProcessError\ntry:\n    _sandbox_git(sandbox, ['add', '--intent-to-add', '-A'])\nexcept ManagedProcessError as e:\n    if 'index.lock' in (e.result.stderr_tail or ''):\n        # stale or contended lock; clear only if no git process is live\n        ...\n    raise","preventionTips":["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."],"tags":["git","sandbox","managed-process","workflow-bench"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}