{"record":{"id":"ee42a1477129b8b5","repo":"nikivdev/code","slug":"dynamic-ambiguous-unresolved-task-message","errorCode":null,"errorMessage":"(dynamic ambiguous/unresolved task message)","messagePattern":"\\(dynamic ambiguous/unresolved task message\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/tasks.rs","lineNumber":1174,"sourceCode":"\nfn ambiguous_task_error(task_name: &str, matches: &[&discover::DiscoveredTask]) -> anyhow::Error {\n    let mut msg = String::new();\n    msg.push_str(&format!(\"task '{}' is ambiguous.\\n\", task_name));\n    msg.push_str(\"Discovered matches:\\n\");\n    for task in matches {\n        msg.push_str(&format!(\"  - {}\\n\", task_reference(task)));\n    }\n    msg.push_str(\"Try one of:\\n\");\n    for task in matches {\n        msg.push_str(&format!(\n            \"  f {}:{}\\n  f run --config {} {}\\n\",\n            task.scope,\n            task.task.name,\n            task.config_path.display(),\n            task.task.name\n        ));\n    }\n    anyhow::anyhow!(msg.trim_end().to_string())\n}\n\nfn resolve_ambiguous_task_match<'a>(\n    query: &str,\n    matches: &[&'a discover::DiscoveredTask],\n    task_resolution: Option<&TaskResolutionConfig>,\n) -> Result<&'a discover::DiscoveredTask> {\n    let Some(policy) = task_resolution else {\n        return Err(ambiguous_task_error(query, matches));\n    };\n\n    let mut route_scope: Option<&str> = None;\n    for (task, scope) in &policy.routes {\n        if task.eq_ignore_ascii_case(query)\n            || matches\n                .iter()\n                .any(|m| m.task.name.eq_ignore_ascii_case(task))\n        {","sourceCodeStart":1156,"sourceCodeEnd":1192,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/tasks.rs#L1156-L1192","documentation":"ambiguous_task_error builds a dynamic message listing all discovered tasks matching a query when the match is not unique or cannot be resolved, then throws it via anyhow. The error tells the user their task query was ambiguous or unresolved and enumerates the candidate task names and config paths so they can disambiguate.","triggerScenarios":"Calling ambiguous_task_error (via select_discovered_task or resolve_ambiguous_task_match) when a short task query matches multiple discovered tasks (different scopes/dirs sharing a name) or matches none in a way the resolver cannot settle, e.g. `f run build` when both frontend and backend define `build`.","commonSituations":"Duplicate task names across projects/scopes in the workspace; partial task name matching several entries; task defined in multiple config files; typos that still fuzzy-match several candidates.","solutions":["Re-run with a more specific task name or include the scope/directory (e.g. `frontend:build` or the full unique name)","Use the candidate list printed in the error to pick the exact task name","Rename duplicate tasks in the relevant config files so names are unique per query","Configure task resolution precedence (task_resolution config) to disambiguate common names"],"exampleFix":"// before (CLI)\nf run build\n// after (disambiguated)\nf run frontend:build   # or use the full unique task name from the error's candidate list","handlingStrategy":"try-catch","validationCode":"let matches = discover_tasks_matching(query)?;\nif matches.len() > 1 {\n    eprintln!(\"query '{}' matches {} tasks: {:?}; qualify with a scope\", query,\n        matches.len(), matches.iter().map(|m| &m.task.name).collect::<Vec<_>>());\n    return;\n}","typeGuard":null,"tryCatchPattern":"match select_discovered_task(query) {\n    Ok(task) => run_task(task),\n    Err(e) if e.to_string().contains(\"Multiple tasks\") || e.to_string().contains(\"ambiguous\") => {\n        eprintln!(\"{}\", e); // error already lists candidates\n        eprintln!(\"re-run with a more specific name or scope\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Name tasks uniquely across scopes and directories","Pass scope-qualified names when multiple projects define the same verb","Configure resolution precedence for recurring ambiguous names","Read the candidate list in the message — it enumerates every matching config path"],"tags":["tasks","ambiguity","name-resolution","cli"],"backgroundTag":"ambiguous-task-name","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}