Hmbown/CodeWhale · error · anyhow::Error

fleet task does not exist

Error message

fleet task {} does not exist

What it means

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.

Solutions

  1. Recreate the run with a complete definition (specs + tasks written atomically) and resubmit; the old task cannot be restarted without its spec.
  2. Confirm the run id and task id pair actually belong to the same ledger (no cross-workspace mixing).
  3. 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.
  4. If specs were intentionally renamed, that invalidates in-flight tasks by design — let them fail and re-queue under the new ids.
Defensive patterns

Strategy: validation

Validate before calling

fn task_spec_exists(state: &FleetLedgerState, task: &FleetTaskState) -> bool {
    state.runs.get(&task.entry.run_id.0)
        .map(|run| run.task_specs.iter().any(|s| s.id == task.entry.task_id))
        .unwrap_or(false)
}

Try / catch

match manager.restart_worker(worker_id) {
    Err(e) if e.to_string().contains("fleet task") && e.to_string().contains("does not exist") => {
        // task entry references a missing spec: fail the task, recreate run with full specs
    }
    other => return other.map(|_| ()),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/827365bfc7770ef6. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/fleet/manager.rs:1080

        let restarted = self.ledger.restart_task_if_unchanged_with_callback(
            &task.entry.run_id,
            &task.entry.task_id,
            worker_id,
            task.status,
            task.entry.attempts,
            latest_seq,
            heartbeat_at,
            &now,
            None,
            task.entry.attempts,
            || {
                if let Some(guard) = coordination_guard.as_mut() {
                    let task_spec = run
                        .task_specs
                        .iter()
                        .find(|spec| spec.id == task.entry.task_id)
                        .ok_or_else(|| {
                            anyhow!("fleet task {} does not exist", task.entry.task_id)
                        })?;
                    self.prepare_registered_restart_generation(
                        guard, &state, task, task_spec, worker_id,
                    )?;
                }
                Ok(())
            },
        )?;
        if !restarted {
            bail!("worker {worker_id} task changed before it could be restarted");
        }
        self.ledger
            .update_run_status(&task.entry.run_id, FleetRunStatus::Running, &timestamp())?;
        Ok(FleetRestartReport {
            run_id: task.entry.run_id.clone(),
            max_workers,
            inspection: self.inspect_worker(worker_id)?,
        })

View on GitHub (pinned to 0c42157ee5)