{"record":{"id":"01cc86ec7ce7c37e","repo":"abhigyanpatwari/GitNexus","slug":"pid-namespace-command-must-not-be-empty","errorCode":null,"errorMessage":"PID-namespace command must not be empty","messagePattern":"PID-namespace command must not be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/proposer_sandbox.py","lineNumber":515,"sourceCode":"    if not result.ok:\n        raise SandboxError(f\"Bubblewrap namespace preflight failed: {result.detail or result.stderr_tail[-1000:]}\")\n    return bwrap\n\n\ndef pid_namespace_command(\n    command: Sequence[str],\n    *,\n    bwrap_bin: Path,\n) -> list[str]:\n    \"\"\"Wrap a trusted host command in an owned PID namespace.\n\n    This boundary deliberately preserves the host filesystem and network; its\n    sole purpose is making every descendant visible to the outer driver even\n    when a nested command creates a new session or process group.\n    \"\"\"\n\n    if not command:\n        raise ValueError(\"PID-namespace command must not be empty\")\n    return [\n        str(bwrap_bin),\n        \"--unshare-user\",\n        \"--unshare-pid\",\n        \"--unshare-ipc\",\n        \"--unshare-uts\",\n        \"--die-with-parent\",\n        \"--new-session\",\n        \"--bind\",\n        \"/\",\n        \"/\",\n        \"--proc\",\n        \"/proc\",\n        \"--dev\",\n        \"/dev\",\n        \"--\",\n        *command,\n    ]","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/proposer_sandbox.py#L497-L533","documentation":"Raised as a ValueError (not SandboxError) by pid_namespace_command when the command sequence is empty. The function builds a bwrap invocation prefixed around the supplied argv; an empty argv would exec bwrap with no command, which is undefined, so the guard rejects it up front. Callers catching SandboxError alone will miss this — it is a ValueError.","triggerScenarios":"Calling pid_namespace_command([], bwrap_bin=...) — passing an empty list/tuple as the command argument.","commonSituations":"Caller built argv from optional flags and produced [] when all were absent; a list comprehension over an empty input yielded an empty command; a refactor passed the wrong variable (e.g. args instead of args.command); a test fixture constructed command=[].","solutions":["Ensure the command sequence has at least one element (the program) before calling: assert command, 'command required'.","Default to an explicit program (e.g. ['/usr/bin/true']) when the dynamic argv is empty rather than calling pid_namespace_command at all.","Fix the upstream argv construction so an empty case is handled before this boundary.","Catch ValueError in addition to SandboxError if this path can be reached from user input."],"exampleFix":"// before\nwrapped = pid_namespace_command(cmd, bwrap_bin=bwrap)  # cmd may be []\n// after\nif not cmd:\n    raise ValueError('cannot wrap an empty command')\nwrapped = pid_namespace_command(cmd, bwrap_bin=bwrap)","handlingStrategy":"validation","validationCode":"def wrap_pid_namespace(command, bwrap_bin):\n    if not command:\n        raise ValueError('cannot wrap an empty command')\n    return pid_namespace_command(command, bwrap_bin=bwrap_bin)","typeGuard":"from collections.abc import Sequence\n\ndef is_non_empty_command(value: object) -> bool:\n    return isinstance(value, (list, tuple)) and len(value) > 0 and all(isinstance(p, str) for p in value)","tryCatchPattern":"try:\n    wrapped = pid_namespace_command(command, bwrap_bin=bwrap)\nexcept ValueError as exc:\n    if 'must not be empty' in str(exc):\n        raise SystemExit('refusing to wrap an empty command')\n    raise","preventionTips":["Assert the command list is non-empty before wrapping.","Default to a real program argv, never [].","Catch ValueError too — this guard is not a SandboxError.","Build argv from explicit program + optional args, not a possibly-empty comprehension."],"tags":["validation","executable","sandbox","programmer-error"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}