{"record":{"id":"c0c2c00ae9da2d6d","repo":"Hmbown/CodeWhale","slug":"fleet-run-does-not-exist-scheduler","errorCode":null,"errorMessage":"Fleet run {} does not exist","messagePattern":"Fleet run (.+?) does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/scheduler.rs","lineNumber":407,"sourceCode":"            worker_id,\n            task.entry.attempts,\n            task_spec,\n            FleetAlertEventClass::RestartExhausted,\n        )?;\n        Ok(())\n    }\n\n    fn launch_queued_work(\n        &self,\n        run_id: &FleetRunId,\n        report: &mut FleetSchedulerReport,\n    ) -> Result<()> {\n        loop {\n            let state = self.ledger.rebuild_state()?;\n            let run = state\n                .runs\n                .get(&run_id.0)\n                .ok_or_else(|| anyhow!(\"Fleet run {} does not exist\", run_id.0))?;\n            let active = active_tasks_for_run(&state, run_id);\n            if active.len() >= self.policy.max_workers_per_run {\n                return Ok(());\n            }\n            let counts = active_counts(&state, run);\n            let Some((worker_id, task)) = self.next_launch(run, &state, &counts) else {\n                return Ok(());\n            };\n            let lease_expires_at = self.lease_expires_at();\n            if !self.ledger.start_task_if_enqueued(\n                &task.entry.run_id,\n                &task.entry.task_id,\n                &worker_id,\n                &self.timestamp(),\n                Some(&lease_expires_at),\n                Some(self.policy.max_workers_per_run),\n                vec![\n                    FleetWorkerEventPayload::Leased {","sourceCodeStart":389,"sourceCodeEnd":425,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/scheduler.rs#L389-L425","documentation":"Thrown by launch_queued_work in the Fleet scheduler when the ledger state has no run matching the requested run_id. The scheduler rebuilds authoritative state from the ledger on each tick and looks up the run by id; an absent id means the run record was never created, was completed and pruned, or the id is wrong. It is a lookup failure before any worker launch decision.","triggerScenarios":"tick_run calls launch_queued_work with a run id whose entry is missing from ledger.rebuild_state(): launching work for a run that was cancelled/cleaned between queueing and the tick, or passing a stale/mistyped run id.","commonSituations":"A queued run was deleted from the ledger while tasks were still pending; scheduler restarted against a fresh/rotated ledger holding different run ids; an off-by-one or truncated id copied from a UI.","solutions":["Re-check the run id against the ledger (`fleet run list` or equivalent) and use a valid, existing run id.","Re-create the Fleet run if its ledger entry was deleted and work must still execute.","Discard stale queued work referencing the nonexistent run instead of retrying the tick.","If the run should exist, inspect ledger storage for corruption or an incorrect data directory (e.g. wrong profile/home pointing at another ledger)."],"exampleFix":"// before\nscheduler.tick_run(RunId(\"run-1042\"))?; // deleted\n// after\nif ledger.rebuild_state()?.runs.contains_key(\"run-1042\") {\n    scheduler.tick_run(RunId(\"run-1042\"))?;\n}","handlingStrategy":"try-catch","validationCode":"// Rust\nlet state = ledger.rebuild_state()?;\nif !state.runs.contains_key(&run_id.0) {\n    eprintln!(\"run {} not in ledger; skipping\", run_id.0);\n    return;\n}","typeGuard":null,"tryCatchPattern":"// Rust\nif let Err(e) = scheduler.tick_run(run_id) {\n    if e.to_string().contains(\"does not exist\") {\n        log::warn!(\"stale run {}: dropping queued work\", run_id.0);\n    } else { return Err(e); }\n}","preventionTips":["Verify run ids against the ledger before enqueuing work.","Cancel queued work when deleting a run so ticks never reference it.","Use one shared data directory so the scheduler and the ledger agree on ids."],"tags":["fleet","scheduler","not-found","ledger"],"backgroundTag":"entity-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"}