{"record":{"id":"4da9d6cae8fb84ca","repo":"Hmbown/CodeWhale","slug":"command-is-required","errorCode":null,"errorMessage":"Command is required","messagePattern":"Command is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/lib.rs","lineNumber":10538,"sourceCode":"        exclude_slash_tmp,\n        cwd,\n        timeout_ms,\n        command,\n    } = args.command;\n\n    let policy = parse_sandbox_policy(\n        &policy,\n        network,\n        writable_root,\n        exclude_tmpdir,\n        exclude_slash_tmp,\n    )?;\n    let cwd = cwd.unwrap_or_else(|| std::env::current_dir().unwrap_or_else(|_| PathBuf::from(\".\")));\n    let timeout = Duration::from_millis(timeout_ms.clamp(1000, 600_000));\n\n    let (program, args) = command\n        .split_first()\n        .ok_or_else(|| anyhow::anyhow!(\"Command is required\"))?;\n    let spec =\n        CommandSpec::program(program, args.to_vec(), cwd.clone(), timeout).with_policy(policy);\n    let manager = SandboxManager::new();\n    let exec_env = manager.prepare(&spec);\n\n    let mut cmd = Command::new(exec_env.program());\n    cmd.args(exec_env.args())\n        .current_dir(&exec_env.cwd)\n        .stdout(Stdio::piped())\n        .stderr(Stdio::piped());\n    child_env::apply_to_command(&mut cmd, child_env::string_map_env(&exec_env.env));\n\n    let mut child = cmd\n        .spawn()\n        .map_err(|e| anyhow::anyhow!(\"Failed to run command: {e}\"))?;\n    let stdout_handle = child\n        .stdout\n        .take()","sourceCodeStart":10520,"sourceCodeEnd":10556,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/lib.rs#L10520-L10556","documentation":"Thrown by the sandboxed command-execution path when the `command` argument is an empty list. `command.split_first()` returns None because there is no program to run, so the code bails before constructing the CommandSpec. The command must contain at least the program name followed by its arguments.","triggerScenarios":"Calling the exec/tool API with `command: []` (or the parsed argv ending up empty after splitting), so `split_first()` finds no program element.","commonSituations":"A tool-call/LLM-generated argument that omitted the command field or passed an empty array; upstream string-splitting on a blank or whitespace-only command string producing an empty vec; config template rendering leaving the command unset.","solutions":["Supply a non-empty command array starting with the program name, e.g. [\"ls\", \"-la\"]","Validate/trim the raw command string before splitting so blank input is rejected earlier","If this comes from a model tool call, strengthen the tool schema/prompt to require the command field","Check upstream parsing (shell-like splitting) that may drop all tokens for whitespace-only input"],"exampleFix":"// before\nlet (program, args) = command\n    .split_first()\n    .ok_or_else(|| anyhow::anyhow!(\"Command is required\"))?;\n// after\nif command.is_empty() {\n    anyhow::bail!(\"Command is required: pass at least the program name, e.g. [\\\"ls\\\", \\\"-la\\\"]\");\n}\nlet (program, args) = command.split_first().unwrap();","handlingStrategy":"validation","validationCode":"// Rust\nif command.is_empty() {\n    bail!(\"Command is required: provide at least a program name\");\n}\nif command[0].trim().is_empty() {\n    bail!(\"Command program name is blank\");\n}","typeGuard":null,"tryCatchPattern":"// Rust\nlet (program, args) = command.split_first()\n    .ok_or_else(|| anyhow::anyhow!(\"Command is required\"))\n    .with_context(|| format!(\"received command argument: {command:?}\"))?;","preventionTips":["Validate tool-call arguments at the schema boundary (minItems: 1 on command arrays)","Trim/split raw command strings and reject whitespace-only input early","For model-generated calls, require the command field in the tool schema and prompt","Log the raw command payload when rejecting so bad inputs are traceable"],"tags":["cli","validation","sandbox","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}