{"record":{"id":"37c104f4cd9ffea1","repo":"Hmbown/CodeWhale","slug":"fleet-task-does-not-exist-manager","errorCode":null,"errorMessage":"Fleet task {} does not exist","messagePattern":"Fleet task (.+?) does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/manager.rs","lineNumber":1119,"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":1101,"sourceCodeEnd":1137,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/manager.rs#L1101-L1137","documentation":"During restart_worker's coordinated restart callback, the manager searches the run's task_specs for the spec matching the task's task_id and fails when no spec matches. The ledger knows the task ran, but the run definition no longer carries a spec with that id — an inconsistency between durable task entries and the run's declared workload.","triggerScenarios":"Calling restart_worker(worker_id) when the task's entry.task_id is not present in run.task_specs — e.g. the run manifest was rewritten, tasks were removed, or the wrong task id was recorded in the ledger.","commonSituations":"Editing a fleet run definition while tasks from an older definition are still in the ledger; copying task entries between runs; hand-editing run JSON.","solutions":["Restore the original run definition so task_specs contains the referenced task id","Re-enqueue the task under the current run's spec ids instead of restarting the old one","Reconcile ledger task ids with run.task_specs before calling restart_worker","Check whether the run was re-created with new spec ids and restart by the new id"],"exampleFix":"// before\nlet spec = run.task_specs.iter().find(|s| s.id == task_id).ok_or(...)?;\n// after\nif !run.task_specs.iter().any(|s| s.id == task_id) {\n    anyhow::bail!(\"task {task_id} was removed from the run; re-enqueue it\");\n}\nlet spec = run.task_specs.iter().find(|s| s.id == task_id).unwrap();","handlingStrategy":"validation","validationCode":"fn task_spec_exists(state: &FleetLedgerState, run_id: &str, task_id: &str) -> bool {\n    state.runs.get(run_id)\n        .map(|r| r.task_specs.iter().any(|s| s.id == task_id))\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not rewrite a run's task_specs while its tasks exist in the ledger","When redefining a run, cancel old tasks first","Keep task ids stable across run definition edits"],"tags":["fleet","ledger","spec-mismatch"],"backgroundTag":"record-not-found","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"}