Hmbown/CodeWhale · error

fleet task spec must include at least one task

Error message

fleet task spec must include at least one task

What it means

validate_task_spec_document requires a spec document to contain at least one task; an empty tasks list — a spec file carrying only a name or security policy — is rejected at load time and at run creation.

Solutions

  1. Add at least one [[tasks]] block with a valid id, name, and instructions
  2. Check the generator/script that produced the spec for an empty-tasks bug
  3. Validate the document before queueing the run

Example fix

# before
[[workers]]
id = "w1"
# after
[[workers]]
id = "w1"

[[tasks]]
id = "build"
name = "Build"
instructions = "Run the build"
Defensive patterns

Strategy: validation

Validate before calling

if doc.tasks.is_empty() {
    return Err("task spec needs at least one [[tasks]] block".into());
}

Try / catch

match load_task_spec_document(path) {
    Ok(doc) => doc,
    Err(e) if e.to_string().contains("must include at least one task") => {
        eprintln!("{}: no [[tasks]] blocks found", path.display());
        return;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling load_task_spec_document or create_queued_run_with_descriptor with a spec file that defines workers/metadata but no [[tasks]] entries.

Common situations: Starting a new spec from an empty template; deleting all task blocks during cleanup; a script generating specs that emits zero [[tasks]] sections due to a loop bug.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/38b8e9095a16db3d. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/fleet/task_spec.rs:159

    let parsed = match path.extension().and_then(|s| s.to_str()) {
        Some("toml") => toml::from_str::<FleetTaskSpecFile>(&raw)
            .with_context(|| format!("parsing TOML fleet task spec {}", path.display()))?,
        _ => serde_json::from_str::<FleetTaskSpecFile>(&raw)
            .with_context(|| format!("parsing JSON fleet task spec {}", path.display()))?,
    };
    let doc = parsed.into_document(fallback_name);
    validate_task_spec_document(&doc)?;
    Ok(doc)
}

pub fn validate_task_spec_document(doc: &FleetTaskSpecDocument) -> Result<()> {
    if doc.security_policy.is_some() {
        bail!(
            "fleet task spec security_policy is a legacy compatibility field, not executable Fleet identity; configure trust, secrets, approvals, sandboxing, and tool authority through Runtime policy"
        );
    }
    if doc.tasks.is_empty() {
        bail!("fleet task spec must include at least one task");
    }
    let mut ids = BTreeSet::new();
    for task in &doc.tasks {
        validate_fleet_identity("task id", &task.id)?;
        if !ids.insert(task.id.clone()) {
            bail!("duplicate fleet task id {}", task.id);
        }
        validate_fleet_name(&format!("task {} name", task.id), &task.name)?;
        if task.instructions.trim().is_empty() {
            bail!("fleet task {} instructions cannot be empty", task.id);
        }
        if let Some(objective) = &task.objective
            && objective.trim().is_empty()
        {
            bail!("fleet task {} objective cannot be empty", task.id);
        }
        validate_worker_profile(&task.id, task.worker.as_ref())?;
        if task

View on GitHub (pinned to 73e0f67d83)