{"record":{"id":"a8875ad1875a4f44","repo":"Hmbown/CodeWhale","slug":"duplicate-fleet-task-id","errorCode":null,"errorMessage":"duplicate fleet task id {}","messagePattern":"duplicate fleet task id (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/task_spec.rs","lineNumber":122,"sourceCode":"        Some(\"toml\") => toml::from_str::<FleetTaskSpecFile>(&raw)\n            .with_context(|| format!(\"parsing TOML fleet task spec {}\", path.display()))?,\n        _ => serde_json::from_str::<FleetTaskSpecFile>(&raw)\n            .with_context(|| format!(\"parsing JSON fleet task spec {}\", path.display()))?,\n    };\n    let doc = parsed.into_document(fallback_name);\n    validate_task_spec_document(&doc)?;\n    Ok(doc)\n}\n\npub fn validate_task_spec_document(doc: &FleetTaskSpecDocument) -> Result<()> {\n    if doc.tasks.is_empty() {\n        bail!(\"fleet task spec must include at least one task\");\n    }\n    let mut ids = BTreeSet::new();\n    for task in &doc.tasks {\n        validate_fleet_identity(\"task id\", &task.id)?;\n        if !ids.insert(task.id.clone()) {\n            bail!(\"duplicate fleet task id {}\", task.id);\n        }\n        validate_fleet_name(&format!(\"task {} name\", task.id), &task.name)?;\n        if task.instructions.trim().is_empty() {\n            bail!(\"fleet task {} instructions cannot be empty\", task.id);\n        }\n        if let Some(objective) = &task.objective\n            && objective.trim().is_empty()\n        {\n            bail!(\"fleet task {} objective cannot be empty\", task.id);\n        }\n        validate_worker_profile(&task.id, task.worker.as_ref())?;\n        validate_tags(&task.id, &task.tags)?;\n        validate_workspace_requirements(task)?;\n    }\n    let mut worker_ids = BTreeSet::new();\n    for worker in &doc.workers {\n        validate_fleet_identity(\"worker id\", &worker.id)?;\n        if !worker_ids.insert(worker.id.clone()) {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/fleet/task_spec.rs#L104-L140","documentation":"validate_task_spec_document collects task ids into a BTreeSet and bails when an id is inserted twice. Task ids are the join key between tasks, worker assignments, receipts and the ledger, so duplicates are rejected up front rather than resolved silently.","triggerScenarios":"Two entries in the tasks array with the same \"id\" field, e.g. two blocks both reading \"id\": \"implement\" after copy-paste.","commonSituations":"Copy-pasting a task block and editing everything but the id; generators that reset an id counter per section; merging two spec files that each used generic ids like \"task-1\".","solutions":["Search the spec for the duplicated id shown in the error and rename one occurrence","Adopt a naming scheme (feature-area-n) so generated specs cannot collide","If merging specs, prefix ids with their source spec name"],"exampleFix":"// before\n{ \"tasks\": [ { \"id\": \"test\", \"name\": \"a\", \"instructions\": \"...\" },\n             { \"id\": \"test\", \"name\": \"b\", \"instructions\": \"...\" } ] }\n\n// after\n{ \"tasks\": [ { \"id\": \"test-api\", \"name\": \"a\", \"instructions\": \"...\" },\n             { \"id\": \"test-tui\", \"name\": \"b\", \"instructions\": \"...\" } ] }","handlingStrategy":"validation","validationCode":"fn task_ids_unique(tasks: &[FleetTaskSpec]) -> bool {\n    let mut seen = std::collections::BTreeSet::new();\n    tasks.iter().all(|t| seen.insert(t.id.as_str()))\n}","typeGuard":"function hasUniqueIds(tasks: { id: string }[]): boolean {\n  return new Set(tasks.map((t) => t.id)).size === tasks.length;\n}","tryCatchPattern":"if let Err(err) = load_task_spec_document(&path) {\n    if let Some(id) = err.to_string().strip_prefix(\"duplicate fleet task id \") {\n        eprintln!(\"task id '{id}' appears twice in {path:?}\");\n    }\n    return Err(err);\n}","preventionTips":["Derive task ids from a single counter or slug namespace when generating specs","Namespace ids by source file when merging spec fragments","De-duplicate ids in a pre-flight check before submitting the fleet run"],"tags":["fleet","task-spec","duplicate-id","validation"],"backgroundTag":"duplicate-identifier","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}