{"record":{"id":"6b4360654baf17d9","repo":"abhigyanpatwari/GitNexus","slug":"managed-command-failed-result-state-exit-resu","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/process_control.py","lineNumber":731,"sourceCode":"    cleanup = f\"{type(error).__name__}: {error}\"\n    detail = f\"{result.detail}; cleanup: {cleanup}\" if result.detail else f\"cleanup: {cleanup}\"\n    return replace(\n        result,\n        state=\"cleanup-failure\",\n        primary_state=result.primary_state or result.state,\n        detail=detail,\n    )\n\n\ndef run_checked(\n    command: Sequence[str] | str,\n    **kwargs: object,\n) -> ManagedProcessResult:\n    \"\"\"Run a managed command and raise with its bounded evidence on failure.\"\"\"\n\n    result = run_managed(command, **kwargs)  # type: ignore[arg-type]\n    if not result.ok:\n        raise ManagedProcessError(command, result)\n    return result\n","sourceCodeStart":713,"sourceCodeEnd":733,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/process_control.py#L713-L733","documentation":"run_checked wraps run_managed: if result.ok is False (state != 'exited' OR returncode != 0) it raises ManagedProcessError, embedding command, full ManagedProcessResult, state, exit code, and either the recorded detail or the last 1000 chars of stderr. This is the canonical 'subprocess failed' signal for callers that want exceptions instead of result inspection.","triggerScenarios":"Any run_checked invocation where the child exits non-zero, times out (state='timed-out'), is force-killed ('forced-kill'), or fails ownership ('ownership-failure'). The message format string exposes whichever of detail / stderr_tail is non-empty.","commonSituations":"git command failing on bad ref / network; tool under test exits 1; timeout exceeded; PID namespace / Bubblewrap not available -> ownership-failure; command not found (state still 'exited' with non-zero).","solutions":["Inspect exc.result: state, returncode, stdout_tail, stderr_tail, detail, primary_state give the actual cause.","If you want to tolerate non-zero exits, call run_managed and check result.ok yourself rather than run_checked.","For ownership-failure details, read result.detail — it tells you whether it was Windows-PID, missing Bubblewrap, etc.","Increase timeout or fix the underlying command based on stderr_tail."],"exampleFix":"// before\nrun_checked(['git','fetch'], timeout=10)\n// after\nres = run_managed(['git','fetch'], timeout=60)\nif not res.ok:\n    log.warning('fetch failed: %s', res.stderr_tail[-500:])\n    # fall back / continue","handlingStrategy":"try-catch","validationCode":"# Decide up-front whether you can tolerate failure.\nresult = run_managed(cmd, timeout=60)\nif result.ok:\n    use(result)\nelse:\n    log.warning('cmd failed state=%s rc=%s detail=%s', result.state, result.returncode, result.detail)\n# Only call run_checked if you want an exception on the not-ok branch.","typeGuard":"from workflow_bench.process_control import ManagedProcessResult\n\ndef is_ok_result(r: ManagedProcessResult) -> bool:\n    return r.state == 'exited' and r.returncode == 0","tryCatchPattern":"from workflow_bench.process_control import ManagedProcessError\n\ntry:\n    run_checked(cmd, timeout=60)\nexcept ManagedProcessError as exc:\n    r = exc.result\n    log.error('cmd=%s state=%s rc=%s', exc.command, r.state, r.returncode)\n    log.error('stderr tail: %s', r.stderr_tail[-500:])\n    if r.state == 'timed-out':\n        increase_timeout_or_split()\n    elif r.state == 'ownership-failure':\n        fix_environment(r.detail)\n    raise","preventionTips":["Prefer run_managed + explicit result.ok check when non-zero exits are expected.","Always log exc.result.detail and stderr_tail — they hold the real cause.","Set sane timeouts at the config boundary, never 0."],"tags":["process-control","subprocess","wrapper","diagnostic"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}