nikivdev/code · error
Suggested command is empty.
Error message
Suggested command is empty.
What it means
Thrown by execute_suggested_command in ask.rs when the AI-suggested command string, after splitting on whitespace, produces no tokens — meaning the suggestion was empty or whitespace-only. This is a defensive check before attempting to dispatch the command.
Source
Thrown at src/ask.rs:251
"Run this command now?".to_string(),
command.trim().to_string(),
];
if !confirm_with_tui("Ask", &lines, "Run suggested command? [Y/n]: ")? {
return Ok(());
}
execute_suggested_command(command)
}
fn execute_suggested_command(command: &str) -> Result<()> {
let tokens = shell_words::split(command).unwrap_or_else(|_| {
command
.split_whitespace()
.map(|part| part.to_string())
.collect()
});
if tokens.is_empty() {
bail!("Suggested command is empty.");
}
let args = match tokens.first().map(|token| token.as_str()) {
Some("f") | Some("flow") => tokens[1..].to_vec(),
_ => tokens,
};
if args.is_empty() {
bail!("Suggested command is incomplete.");
}
let exe = std::env::current_exe()?;
let status = Command::new(&exe)
.args(&args)
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()
.with_context(|| format!("failed to execute suggested command via {}", exe.display()))?;View on GitHub (pinned to a747e741ae)
Solutions
- Verify the AI response actually contains a non-empty command before offering execution
- Regenerate or re-prompt if the suggestion came back empty
- Handle the empty case upstream (skip execute_suggested_command) instead of passing blank strings
Example fix
// before
execute_suggested_command(&suggestion.command)?;
// after
if !suggestion.command.trim().is_empty() {
execute_suggested_command(&suggestion.command)?;
} Defensive patterns
Strategy: validation
Validate before calling
fn suggestion_usable(cmd: &str) -> bool {
!cmd.split_whitespace().next().unwrap_or("").is_empty()
}
if !suggestion_usable(&suggestion.command) {
eprintln!("skipping empty AI suggestion");
return Ok(());
} Try / catch
match execute_suggested_command(&cmd) {
Err(e) if e.to_string().contains("Suggested command is empty") => {
eprintln!("AI returned no command; re-prompt or skip.");
Ok(())
}
other => other,
} Prevention
- Check suggestion.command.trim() is non-empty before offering execution
- Validate AI responses structurally before dispatching commands
- Skip gracefully rather than erroring when the suggestion is blank
When it happens
Trigger: maybe_offer_execute passes an AI suggestion to execute_suggested_command where command is "" or " ", so tokens.is_empty() triggers the bail.
Common situations: AI model returns an empty command field; prompt/response parsing strips everything; upstream truncation leaves only whitespace; a suggestion template whose placeholder was never filled.
Related errors
- prompt is empty
- Token cannot be empty
- todo title cannot be empty
- No prompt provided. Usage: f agents run {} "your prompt here
- agent run requires a non-empty query
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/f3fca83165acdfec.
Report an issue: GitHub.