{"record":{"id":"dc79562b73dca0f9","repo":"nikivdev/code","slug":"suggested-command-is-incomplete","errorCode":null,"errorMessage":"Suggested command is incomplete.","messagePattern":"Suggested command is incomplete\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/ask.rs","lineNumber":259,"sourceCode":"}\n\nfn execute_suggested_command(command: &str) -> Result<()> {\n    let tokens = shell_words::split(command).unwrap_or_else(|_| {\n        command\n            .split_whitespace()\n            .map(|part| part.to_string())\n            .collect()\n    });\n    if tokens.is_empty() {\n        bail!(\"Suggested command is empty.\");\n    }\n\n    let args = match tokens.first().map(|token| token.as_str()) {\n        Some(\"f\") | Some(\"flow\") => tokens[1..].to_vec(),\n        _ => tokens,\n    };\n    if args.is_empty() {\n        bail!(\"Suggested command is incomplete.\");\n    }\n\n    let exe = std::env::current_exe()?;\n    let status = Command::new(&exe)\n        .args(&args)\n        .stdin(Stdio::inherit())\n        .stdout(Stdio::inherit())\n        .stderr(Stdio::inherit())\n        .status()\n        .with_context(|| format!(\"failed to execute suggested command via {}\", exe.display()))?;\n    if !status.success() {\n        bail!(\n            \"suggested command exited unsuccessfully with status {}\",\n            status\n        );\n    }\n    Ok(())\n}","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ask.rs#L241-L277","documentation":"Flow lets the user accept an AI-suggested command and re-executes it through the current binary. If, after mapping the 'f'/'flow' alias to the executable, the token list is empty, there is literally nothing to run, so execute_suggested_command bails with this message instead of spawning an empty process.","triggerScenarios":"The user accepts a suggested command that consists only of the bare 'f' or 'flow' token (or an empty suggestion), so tokens[1..] is empty after the alias strip and args.is_empty() is true.","commonSituations":"The AI model responds with just 'f' or 'flow' with no subcommand; a UI/clipboard flow truncated the suggestion; a suggestion string with only whitespace was accepted.","solutions":["Check the accepted suggestion before executing: reject or re-ask when it has no subcommand after the 'f'/'flow' prefix","Improve the AI prompt to always emit 'f <subcommand> [args]' and validate the suggestion before offering it to the user","Have the fallback path print help (e.g. run the binary with '--help') instead of erroring on an empty command"],"exampleFix":"// before\nif args.is_empty() {\n    bail!(\"Suggested command is incomplete.\");\n}\n// after\nif args.is_empty() {\n    eprintln!(\"Suggestion had no subcommand; showing help instead.\");\n    let status = Command::new(&exe).arg(\"--help\").status()?;\n    return Ok(());\n}","handlingStrategy":"validation","validationCode":"fn is_executable_suggestion(tokens: &[String]) -> bool {\n    match tokens.first().map(|s| s.as_str()) {\n        Some(\"f\") | Some(\"flow\") => tokens.len() > 1,\n        Some(_) => !tokens.is_empty(),\n        None => false,\n    }\n}\n// call before executing: if !is_executable_suggestion(&tokens) { re-prompt }","typeGuard":null,"tryCatchPattern":"match maybe_offer_execute(...) {\n    Err(e) if e.to_string().contains(\"incomplete\") => println!(\"Suggestion had no command; nothing to run.\"),\n    other => other?,\n}","preventionTips":["Validate suggestions contain a subcommand before offering them to the user","Prompt the AI to always emit 'f <subcommand> [args]'","Trim and tokenize the suggestion in the UI layer before acceptance","Show help as a fallback instead of failing"],"tags":["cli","input-validation","suggested-command"],"backgroundTag":"incomplete-command-input","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}