nikivdev/code · error

lifecycle task '{}' not found

Error message

lifecycle task '{}' not found

What it means

run_required_task wraps run_task for tasks that must exist (the configured up/down task). When run_task fails specifically because the task name is not in the config (detected via is_task_not_found), it re-raises a clearer 'lifecycle task not found' error; other errors pass through unchanged.

Source

Thrown at src/lifecycle.rs:92

    if let Some(domains_cfg) = lifecycle.domains.as_ref() {
        domain_action_ran = run_domains_down(domains_cfg)?;
    }

    if !task_ran && !domain_action_ran {
        bail!(
            "No lifecycle down action found. Define task 'down', set [lifecycle].down_task, or enable [lifecycle.domains] cleanup in {}",
            project.flow_path.display()
        );
    }

    Ok(())
}

fn run_required_task(config_path: &Path, task_name: &str, args: Vec<String>) -> Result<bool> {
    match run_task(config_path, task_name, args) {
        Ok(()) => Ok(true),
        Err(err) if is_task_not_found(&err) => {
            bail!("lifecycle task '{}' not found", task_name);
        }
        Err(err) => Err(err),
    }
}

fn run_optional_task_chain(
    config_path: &Path,
    candidates: &[&str],
    args: Vec<String>,
) -> Result<bool> {
    for name in candidates {
        match run_task(config_path, name, args.clone()) {
            Ok(()) => return Ok(true),
            Err(err) if is_task_not_found(&err) => continue,
            Err(err) => return Err(err),
        }
    }
    Ok(false)

View on GitHub (pinned to a747e741ae)

Solutions

  1. Make the task name in [lifecycle].up_task/down_task match an existing [tasks] entry in the same flow.toml
  2. Add the missing task definition under [tasks]
  3. Search flow.toml for the task name from the error and reconcile spellings

Example fix

// before (flow.toml)
[lifecycle]
up_task = "strt"
// after
[lifecycle]
up_task = "start"
Defensive patterns

Strategy: validation

Validate before calling

let cfg = std::fs::read_to_string("flow.toml")?;
for task in ["up", "dev", "down"] {
    if cfg.contains(&format!("{} =", task)) { println!("task {} defined", task); }
}
// confirm any up_task/down_task value appears as a [tasks] key before running

Try / catch

match run_required_task(&path, "start", args) {
    Ok(true) => {},
    Err(e) if e.to_string().contains("lifecycle task 'start' not found") => {
        eprintln!("Rename the task in [lifecycle] or add a 'start' task to [tasks]");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: [lifecycle].up_task or down_task names a task that is absent from flow.toml's task definitions — e.g. up_task = "start" but only an 'up' task is defined.

Common situations: Typo in the up_task/down_task value; task deleted or renamed in flow.toml while [lifecycle] still references the old name; copying a lifecycle block between projects with different task names.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/be10ec55caea2934. Report an issue: GitHub.