{"record":{"id":"6d7e18c92334ead5","repo":"nikivdev/code","slug":"ai-task-is-ambiguous-matches-try-one","errorCode":null,"errorMessage":"AI task '{}' is ambiguous.\nMatches:\n  - {}\nTry one of the full selectors above.","messagePattern":"AI task '(.+?)' is ambiguous\\.\nMatches:\n  - (.+?)\nTry one of the full selectors above\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/ai_tasks.rs","lineNumber":228,"sourceCode":"            })\n            .collect();\n    }\n\n    if matches.is_empty() {\n        return Ok(None);\n    }\n    if matches.len() == 1 {\n        return Ok(Some(matches[0]));\n    }\n\n    let mut msg = String::new();\n    msg.push_str(&format!(\"AI task '{}' is ambiguous.\\n\", selector));\n    msg.push_str(\"Matches:\\n\");\n    for m in &matches {\n        msg.push_str(&format!(\"  - {}\\n\", m.id));\n    }\n    msg.push_str(\"Try one of the full selectors above.\");\n    bail!(msg);\n}\n\npub fn run_task(task: &DiscoveredAiTask, project_root: &Path, args: &[String]) -> Result<()> {\n    if !task_has_workspace(task, project_root) {\n        return run_task_via_moon(task, project_root, args);\n    }\n\n    let runtime = std::env::var(\"FLOW_AI_TASK_RUNTIME\")\n        .ok()\n        .unwrap_or_else(|| \"cached\".to_string())\n        .to_ascii_lowercase();\n\n    if runtime == \"moon-run\" || runtime == \"moon\" {\n        return run_task_via_moon(task, project_root, args);\n    }\n\n    match run_task_cached(task, project_root, args) {\n        Ok(()) => Ok(()),","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/ai_tasks.rs#L210-L246","documentation":"Thrown by select_task in src/ai_tasks.rs when the AI task selector given on the command line matches more than one discovered task. The library cannot guess which task the user meant, so it bails with the list of matching task IDs and asks the user to use a full selector.","triggerScenarios":"Calling select_task (or a CLI command that resolves an AI task by name) with a selector string that is a non-unique prefix or substring of multiple task IDs, e.g. 'build' when both 'build-docs' and 'build-app' exist.","commonSituations":"Projects with similarly named AI tasks (shared prefixes); users typing short abbreviations; newly added tasks that collide with an existing prefix after a version change.","solutions":["Re-run with the exact full task ID shown in the 'Matches:' list","Disambiguate with a longer prefix that uniquely identifies one task","Rename one of the colliding tasks so their IDs no longer share the ambiguous prefix"],"exampleFix":"// before\nrun_ai_task(\"build\")?;\n// after\nrun_ai_task(\"build-docs\")?; // or another full selector from the Matches list","handlingStrategy":"validation","validationCode":"fn is_unambiguous<'a>(tasks: &[&'a AiTask], selector: &str) -> bool {\n    tasks.iter().filter(|t| t.id.starts_with(selector)).count() == 1\n}","typeGuard":null,"tryCatchPattern":"match select_task(selector) {\n    Ok(task) => run_task(task, root, args),\n    Err(e) if e.to_string().contains(\"is ambiguous\") => {\n        eprintln!(\"{}\\nPlease pick a full task ID.\", e);\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Use the full task ID or a uniquely long prefix","List available tasks first and pick from that list","Rename tasks that share prefixes"],"tags":["cli","ambiguity","task-resolution","argument-error"],"backgroundTag":"ambiguous-selector","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}