{"record":{"id":"c3a0257789345e0c","repo":"Hmbown/CodeWhale","slug":"ambiguous-task-prefix-matches-tasks","errorCode":null,"errorMessage":"Ambiguous task prefix '{}': matches {} tasks","messagePattern":"Ambiguous task prefix '(.+?)': matches (.+?) tasks","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/task_manager.rs","lineNumber":3318,"sourceCode":") -> Result<String> {\n    let visible = |record: &TaskRecord| {\n        owner_session_id.is_none_or(|owner_session_id| {\n            record.owner_session_id.as_deref() == Some(owner_session_id)\n        })\n    };\n    if tasks.get(id_or_prefix).is_some_and(visible) {\n        return Ok(id_or_prefix.to_string());\n    }\n    let matches = tasks\n        .iter()\n        .filter(|(id, record)| id.starts_with(id_or_prefix) && visible(record))\n        .map(|(id, _)| id)\n        .cloned()\n        .collect::<Vec<_>>();\n    match matches.len() {\n        0 => bail!(\"Task not found: {id_or_prefix}\"),\n        1 => Ok(matches[0].clone()),\n        _ => bail!(\n            \"Ambiguous task prefix '{}': matches {} tasks\",\n            id_or_prefix,\n            matches.len()\n        ),\n    }\n}\n\nfn resolve_task_id_visible_to_operator(\n    tasks: &HashMap<String, TaskRecord>,\n    id_or_prefix: &str,\n    owner_session_id: &str,\n    execution_scope: &str,\n) -> Result<String> {\n    let visible = |record: &TaskRecord| {\n        record.owner_session_id.as_deref() == Some(owner_session_id)\n            || record.owner_session_id.is_none()\n                && !execution_scope.is_empty()\n                && record.execution_scope.as_deref() == Some(execution_scope)","sourceCodeStart":3300,"sourceCodeEnd":3336,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/task_manager.rs#L3300-L3336","documentation":"The same prefix-resolution path throws this when the supplied id_or_prefix is not unique: more than one visible task id starts with that prefix. The library refuses to guess and reports the match count.","triggerScenarios":"Calling resolve (get/update/complete by id_or_prefix) with a short prefix like \"1\" or \"a\" that matches multiple visible task ids.","commonSituations":"Users abbreviating task ids too aggressively in agent tool calls; ids sharing a common timestamp or run prefix.","solutions":["Provide more characters of the task id so the prefix matches exactly one task.","Use the full task id copied from the task list output.","List tasks filtered to the prefix to see the ambiguous matches and pick the intended one."],"exampleFix":"// before\nlet id = manager.resolve_task_id_visible_to(\"a1\", actor).await?; // matches a10, a11\n// after\nlet id = manager.resolve_task_id_visible_to(\"a10\", actor).await?;","handlingStrategy":"validation","validationCode":"let matching = tasks.iter().filter(|t| t.id.starts_with(prefix)).count();\nif matching != 1 { anyhow::bail!(\"prefix '{prefix}' matches {matching} tasks; use a longer prefix\"); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer full ids; only use prefixes when you know they are unique.","Check the match count by listing tasks with the prefix before resolving.","Avoid very short prefixes (1-2 chars) against many tasks."],"tags":["lookup","ambiguity","task-management"],"backgroundTag":"invalid-argument-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}