{"record":{"id":"b708160125152909","repo":"abhigyanpatwari/GitNexus","slug":"timeout-and-tail-bytes-must-be-positive-terminate","errorCode":null,"errorMessage":"timeout and tail_bytes must be positive; terminate_grace must be non-negative","messagePattern":"timeout and tail_bytes must be positive; terminate_grace must be non-negative","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/process_control.py","lineNumber":428,"sourceCode":"def _run_managed_inner(\n    command: Sequence[str] | str,\n    *,\n    cwd: Path | str | None = None,\n    env: Mapping[str, str] | None = None,\n    shell: bool = False,\n    timeout: float,\n    terminate_grace: float = DEFAULT_TERMINATE_GRACE,\n    tail_bytes: int = MAX_TAIL_BYTES,\n    require_pid_namespace: bool = False,\n    stdin_data: bytes | None = None,\n    capture_stdout_bytes: int | None = None,\n    _ownership_slot: list[tuple[subprocess.Popen[bytes], _WindowsJob | None, int | None]],\n) -> ManagedProcessResult:\n    \"\"\"Implementation registered with an outer post-spawn ownership guard.\"\"\"\n\n    started = time.monotonic()\n    if timeout <= 0 or terminate_grace < 0 or tail_bytes <= 0:\n        raise ValueError(\"timeout and tail_bytes must be positive; terminate_grace must be non-negative\")\n    if capture_stdout_bytes is not None and capture_stdout_bytes <= 0:\n        raise ValueError(\"capture_stdout_bytes must be positive when supplied\")\n    if require_pid_namespace:\n        if os.name == \"nt\":\n            return _empty_result(\"ownership-failure\", started, \"PID-namespace execution is not supported on Windows\")\n        if not _pid_namespace_wrapper(command, shell):\n            return _empty_result(\n                \"ownership-failure\",\n                started,\n                \"required Bubblewrap --unshare-pid/--die-with-parent ownership is absent\",\n            )\n\n    try:\n        process, job, ownership = _spawn(\n            command,\n            cwd=cwd,\n            env=env,\n            shell=shell,","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/process_control.py#L410-L446","documentation":"First validation block of _run_managed_inner: timeout must be > 0, terminate_grace must be >= 0, and tail_bytes must be > 0. These are caller-supplied numeric knobs; a violation is a programming error, not a runtime condition, and the function refuses to spawn anything.","triggerScenarios":"Calling run_managed / run_checked / _run_managed_inner with timeout=0 or negative, terminate_grace negative, or tail_bytes <= 0. Often a default-value bug or a config-driven value parsed as 0.","commonSituations":"Loading timeout from env/config that defaults to 0 when unset; passing `tail_bytes=0` thinking it disables capping (it doesn't — use MAX_TAIL_BYTES); passing terminate_grace=-1 hoping to skip grace.","solutions":["Pass a positive timeout (e.g. 60) and a non-negative terminate_grace (default DEFAULT_TERMINATE_GRACE).","If you need to disable tail capping, pass MAX_TAIL_BYTES explicitly, not 0.","Validate numeric config at parse time so a missing key falls back to a sane default rather than 0.","Add a unit test asserting the validators reject zero/negative values."],"exampleFix":"// before\nrun_managed(['git','status'], timeout=0, tail_bytes=0)\n// after\nrun_managed(['git','status'], timeout=60, tail_bytes=MAX_TAIL_BYTES)","handlingStrategy":"validation","validationCode":"def validate_run_args(*, timeout: float, terminate_grace: float, tail_bytes: int) -> None:\n    if timeout <= 0:\n        raise ValueError('timeout must be > 0')\n    if terminate_grace < 0:\n        raise ValueError('terminate_grace must be >= 0')\n    if tail_bytes <= 0:\n        raise ValueError('tail_bytes must be > 0; use MAX_TAIL_BYTES to disable capping')\n\n# call before run_managed(...)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass explicit positive numerics — do not let config defaults fall through as 0.","Use MAX_TAIL_BYTES (not 0) to disable tail capping.","Add unit tests covering zero/negative for each numeric knob."],"tags":["validation","process-control","precondition","numeric"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}