{"record":{"id":"b4705facab2664e0","repo":"Hmbown/CodeWhale","slug":"fleet-task-environment-variable-name-cannot-be","errorCode":null,"errorMessage":"fleet task {} environment variable name cannot be empty","messagePattern":"fleet task (.+?) environment variable name cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/task_spec.rs","lineNumber":387,"sourceCode":"        }\n        if !seen.insert(tag) {\n            bail!(\"fleet task {task_id} has duplicate tag {tag}\");\n        }\n    }\n    Ok(())\n}\n\nfn validate_workspace_requirements(task: &FleetTaskSpec) -> Result<()> {\n    let Some(workspace) = &task.workspace else {\n        return Ok(());\n    };\n    let env = workspace.environment.as_ref();\n    for name in env\n        .into_iter()\n        .flat_map(|env| env.required.iter().chain(env.allowlist.iter()))\n    {\n        if name.trim().is_empty() {\n            bail!(\n                \"fleet task {} environment variable name cannot be empty\",\n                task.id\n            );\n        }\n    }\n    Ok(())\n}\n\nfn verify_exit_code(exit_code: Option<i32>) -> FleetTaskVerification {\n    match exit_code {\n        Some(0) => pass(\"exit_code=0\"),\n        Some(code) => fail(\n            FleetTaskFailureKind::Task,\n            0.0,\n            format!(\"exit_code={code}\"),\n            \"worker task exited unsuccessfully\",\n        ),\n        None => fail(","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/fleet/task_spec.rs#L369-L405","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open the task spec and remove or fix the empty/whitespace entry in `workspace.environment.required` or `.allowlist`.","If the entry comes from a template, make the template skip undefined names instead of emitting \"\".","Re-run the fleet command that loads the spec to confirm validation passes."],"exampleFix":"# before\n[workspace.environment]\nrequired = [\"\", \"DATABASE_URL\"]\nallowlist = [\"PATH\", \" \"]\n\n# after\n[workspace.environment]\nrequired = [\"DATABASE_URL\"]\nallowlist = [\"PATH\"]","handlingStrategy":"validation","validationCode":"fn check_env_names(required: &[String], allowlist: &[String]) -> Result<(), String> {\n    for name in required.iter().chain(allowlist) {\n        if name.trim().is_empty() {\n            return Err(format!(\"empty environment variable name: {name:?}\"));\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate environment lists from a typed struct, never by string-joining optional names.","Filter out empty entries at the source: names.iter().filter(|n| !n.trim().is_empty()).","Add a spec-lint CI check that validates the whole task document before submission."],"tags":["fleet","task-spec","environment","validation","rust"],"backgroundTag":"invalid-env-var-name","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}