Hmbown/CodeWhale · error

fleet task {} environment variable name cannot be empty

Error message

fleet task {} environment variable name cannot be empty

What it means

Fleet task workspace validation found an environment-variable name that is empty or whitespace-only. `validate_workspace_requirements` iterates `workspace.environment.required` and `workspace.environment.allowlist` and requires every entry to be non-empty after trimming. The goal is to stop malformed env contracts (an empty name is unmatchable and would silently break sandbox wiring) before the worker launches.

Source

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

        }
        if !seen.insert(tag) {
            bail!("fleet task {task_id} has duplicate tag {tag}");
        }
    }
    Ok(())
}

fn validate_workspace_requirements(task: &FleetTaskSpec) -> Result<()> {
    let Some(workspace) = &task.workspace else {
        return Ok(());
    };
    let env = workspace.environment.as_ref();
    for name in env
        .into_iter()
        .flat_map(|env| env.required.iter().chain(env.allowlist.iter()))
    {
        if name.trim().is_empty() {
            bail!(
                "fleet task {} environment variable name cannot be empty",
                task.id
            );
        }
    }
    Ok(())
}

fn verify_exit_code(exit_code: Option<i32>) -> FleetTaskVerification {
    match exit_code {
        Some(0) => pass("exit_code=0"),
        Some(code) => fail(
            FleetTaskFailureKind::Task,
            0.0,
            format!("exit_code={code}"),
            "worker task exited unsuccessfully",
        ),
        None => fail(

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Open the task spec and remove or fix the empty/whitespace entry in `workspace.environment.required` or `.allowlist`.
  2. If the entry comes from a template, make the template skip undefined names instead of emitting "".
  3. Re-run the fleet command that loads the spec to confirm validation passes.

Example fix

# before
[workspace.environment]
required = ["", "DATABASE_URL"]
allowlist = ["PATH", " "]

# after
[workspace.environment]
required = ["DATABASE_URL"]
allowlist = ["PATH"]
Defensive patterns

Strategy: validation

Validate before calling

fn check_env_names(required: &[String], allowlist: &[String]) -> Result<(), String> {
    for name in required.iter().chain(allowlist) {
        if name.trim().is_empty() {
            return Err(format!("empty environment variable name: {name:?}"));
        }
    }
    Ok(())
}

Prevention

When it happens

Trigger: A task spec with `workspace.environment.required = ["", "FOO"]`, an allowlist entry of " " or "\t", or a templating bug that emits an empty string for an optional variable name.

Common situations: Spec templates that join a list with a stray comma producing an empty element; renaming a variable to an empty placeholder; copy-paste from a spreadsheet that keeps a whitespace-only cell.

Related errors


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