Hmbown/CodeWhale · error
Command is required
Error message
Command is required
What it means
Returned by run_sandbox_command when the command vector is empty, so split_first() yields no program to execute. It is a usage-contract error: the sandbox runner requires at least one element (the program) before it can build a CommandSpec. The policy, cwd, and timeout are parsed first, so those must already be valid.
Source
Thrown at crates/tui/src/lib.rs:8916
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 8880682c63)
Solutions
- Pass a non-empty command: at minimum the program name, followed by its arguments
- If driving SandboxCommand::Run programmatically, assert !command.is_empty() before calling
- Tighten the CLI definition to require at least one value (num_args(1..) with a non-empty value_parser) so the error surfaces at parse time with clap's own message
Example fix
// before: empty argv reaches the runner
let (program, args) = command.split_first()
.ok_or_else(|| anyhow::anyhow!("Command is required"))?;
// after: reject at the CLI boundary
#[arg(required = true, num_args = 1..)]
command: Vec<String>, Defensive patterns
Strategy: validation
Validate before calling
// Rust: gate before dispatch
if command.is_empty() {
return Err(anyhow::anyhow!("sandbox run requires a program plus optional args"));
} Type guard
// Narrow an optional command into a guaranteed non-empty invocation
fn as_invocation(cmd: &[String]) -> Option<(&str, &[String])> {
cmd.split_first().map(|(p, a)| (p.as_str(), a))
} Prevention
- Quote variables when scripting the CLI so empty expansions are visible
- Require at least one command element in arg definitions (num_args(1..))
- Unit-test the empty-argv path in wrappers around SandboxCommand::Run
When it happens
Trigger: Invoking the sandbox run subcommand with an empty command list: `--command=` with an empty value, an argv built by a script where a variable expands to nothing (unquoted empty shell variable), or a programmatic caller passing Vec::new() as command to SandboxCommand::Run.
Common situations: Shell scripts forwarding unset variables into the CLI, wrapper tools that split an empty string into zero arguments, or clap arg definitions allowing zero values (num_args(0..)) for the command field.
Related errors
- Usage: node scripts/release/assemble-release-assets.js INP
- Invalid GitHub repository: ${repo}
- Invalid release tag: ${tag}
- Usage: node scripts/release/ensure-release-assets-absent.js
- unknown argument: ${arg}
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/4da9d6cae8fb84ca.
Report an issue: GitHub.