{"record":{"id":"827365bfc7770ef6","repo":"Hmbown/CodeWhale","slug":"fleet-task-does-not-exist","errorCode":null,"errorMessage":"fleet task {} does not exist","messagePattern":"fleet task (.+?) does not exist","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/manager.rs","lineNumber":1080,"sourceCode":"        let restarted = self.ledger.restart_task_if_unchanged_with_callback(\n            &task.entry.run_id,\n            &task.entry.task_id,\n            worker_id,\n            task.status,\n            task.entry.attempts,\n            latest_seq,\n            heartbeat_at,\n            &now,\n            None,\n            task.entry.attempts,\n            || {\n                if let Some(guard) = coordination_guard.as_mut() {\n                    let task_spec = run\n                        .task_specs\n                        .iter()\n                        .find(|spec| spec.id == task.entry.task_id)\n                        .ok_or_else(|| {\n                            anyhow!(\"fleet task {} does not exist\", task.entry.task_id)\n                        })?;\n                    self.prepare_registered_restart_generation(\n                        guard, &state, task, task_spec, worker_id,\n                    )?;\n                }\n                Ok(())\n            },\n        )?;\n        if !restarted {\n            bail!(\"worker {worker_id} task changed before it could be restarted\");\n        }\n        self.ledger\n            .update_run_status(&task.entry.run_id, FleetRunStatus::Running, &timestamp())?;\n        Ok(FleetRestartReport {\n            run_id: task.entry.run_id.clone(),\n            max_workers,\n            inspection: self.inspect_worker(worker_id)?,\n        })","sourceCodeStart":1062,"sourceCodeEnd":1098,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/fleet/manager.rs#L1062-L1098","documentation":"During a worker restart, the callback that prepares the next launch generation must find the task's spec in run.task_specs by spec.id == task.entry.task_id. The task entry in the ledger references a task id that the run's spec list does not contain, so no launch spec (model, cwd, profiles) can be built and the restart is aborted before consuming the attempt.","triggerScenarios":"restart_worker (or the restart callback path) where the ledger's task entry names a task_id that is not in the run's task_specs — run definition edited after tasks were leased, ledger files mixed across run versions, or a partial write that recorded the task without its spec.","commonSituations":"Editing a saved fleet run definition between submissions; resuming old ledger state with newer code that changed spec ids; copy-pasting ledger fragments between workspaces; crashes between task-entry append and spec append.","solutions":["Recreate the run with a complete definition (specs + tasks written atomically) and resubmit; the old task cannot be restarted without its spec.","Confirm the run id and task id pair actually belong to the same ledger (no cross-workspace mixing).","Audit how the run was authored: task ids must match a spec id in the same run payload — fix the authoring tooling if it can emit orphans.","If specs were intentionally renamed, that invalidates in-flight tasks by design — let them fail and re-queue under the new ids."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"fn task_spec_exists(state: &FleetLedgerState, task: &FleetTaskState) -> bool {\n    state.runs.get(&task.entry.run_id.0)\n        .map(|run| run.task_specs.iter().any(|s| s.id == task.entry.task_id))\n        .unwrap_or(false)\n}\n","typeGuard":null,"tryCatchPattern":"match manager.restart_worker(worker_id) {\n    Err(e) if e.to_string().contains(\"fleet task\") && e.to_string().contains(\"does not exist\") => {\n        // task entry references a missing spec: fail the task, recreate run with full specs\n    }\n    other => return other.map(|_| ()),\n}","preventionTips":["Submit runs as one atomic payload: specs and tasks together.","Never rename spec ids while tasks from that run are in flight.","Validate run authoring input: every task_id must match a spec id in the same run.","Avoid hand-editing ledger task entries."],"tags":["fleet","restart","task-spec","data-integrity","not-found"],"backgroundTag":"dangling-foreign-key","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}