Hmbown/CodeWhale · error
Command is required
Error message
Command is required
What it means
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.
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
Example fix
// before
let (program, args) = command
.split_first()
.ok_or_else(|| anyhow::anyhow!("Command is required"))?;
// after
if command.is_empty() {
anyhow::bail!("Command is required: pass at least the program name, e.g. [\"ls\", \"-la\"]");
}
let (program, args) = command.split_first().unwrap(); Defensive patterns
Strategy: validation
Validate before calling
// Rust
if command.is_empty() {
bail!("Command is required: provide at least a program name");
}
if command[0].trim().is_empty() {
bail!("Command program name is blank");
} Try / catch
// Rust
let (program, args) = command.split_first()
.ok_or_else(|| anyhow::anyhow!("Command is required"))
.with_context(|| format!("received command argument: {command:?}"))?; Prevention
- 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
When it happens
Trigger: Calling the exec/tool API with `command: []` (or the parsed argv ending up empty after splitting), so `split_first()` finds no program element.
Common situations: 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.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- --attempts must be an integer from 1 to 20
- --channel, --version and --reason are required
- Choose one Runtime --thread ID.
- Invalid pet recording segment limit.
- Provide either --command or --url for `mcp add`.
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/4da9d6cae8fb84ca.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/lib.rs:10538
exclude_slash_tmp,
cwd,
timeout_ms,
command,
} = args.command;
let policy = parse_sandbox_policy(
&policy,
network,
writable_root,
exclude_tmpdir,
exclude_slash_tmp,
)?;
let cwd = cwd.unwrap_or_else(|| std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")));
let timeout = Duration::from_millis(timeout_ms.clamp(1000, 600_000));
let (program, args) = command
.split_first()
.ok_or_else(|| anyhow::anyhow!("Command is required"))?;
let spec =
CommandSpec::program(program, args.to_vec(), cwd.clone(), timeout).with_policy(policy);
let manager = SandboxManager::new();
let exec_env = manager.prepare(&spec);
let mut cmd = Command::new(exec_env.program());
cmd.args(exec_env.args())
.current_dir(&exec_env.cwd)
.stdout(Stdio::piped())
.stderr(Stdio::piped());
child_env::apply_to_command(&mut cmd, child_env::string_map_env(&exec_env.env));
let mut child = cmd
.spawn()
.map_err(|e| anyhow::anyhow!("Failed to run command: {e}"))?;
let stdout_handle = child
.stdout
.take()View on GitHub (pinned to 73e0f67d83)