{"record":{"id":"a6ee17ee3bb4903f","repo":"Hmbown/CodeWhale","slug":"fleet-task-task-id-field-cannot-be-empty","errorCode":null,"errorMessage":"fleet task {task_id} {field} cannot be empty","messagePattern":"fleet task (.+?) (.+?) cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/fleet/task_spec.rs","lineNumber":252,"sourceCode":"    };\n    validate_worker_selector(\n        task_id,\n        \"worker.agent_profile\",\n        worker.agent_profile.as_deref(),\n    )?;\n    validate_worker_token(task_id, \"worker.loadout\", worker.loadout.as_deref())?;\n    validate_worker_token(task_id, \"worker.model_class\", worker.model_class.as_deref())?;\n    validate_worker_model(task_id, worker.model.as_deref())?;\n    Ok(())\n}\n\nfn validate_worker_selector(task_id: &str, field: &str, value: Option<&str>) -> Result<()> {\n    let Some(value) = value else {\n        return Ok(());\n    };\n    let trimmed = value.trim();\n    if trimmed.is_empty() {\n        bail!(\"fleet task {task_id} {field} cannot be empty\");\n    }\n    if trimmed != value || value.len() > MAX_FLEET_NAME_BYTES || value.chars().any(char::is_control)\n    {\n        bail!(\n            \"fleet task {task_id} {field} must be one printable selector no longer than {MAX_FLEET_NAME_BYTES} bytes\"\n        );\n    }\n    Ok(())\n}\n\nfn validate_worker_token(task_id: &str, field: &str, value: Option<&str>) -> Result<()> {\n    let Some(value) = value else {\n        return Ok(());\n    };\n    let trimmed = value.trim();\n    if trimmed.is_empty() {\n        bail!(\"fleet task {task_id} {field} cannot be empty\");\n    }","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/fleet/task_spec.rs#L234-L270","documentation":"Worker selector fields are optional, but when present they must be non-empty. validate_worker_selector returns Ok for None but bails on an empty or whitespace-only Some value. This prevents passing a blank selector that would never match a worker.","triggerScenarios":"validate_worker_profile (via validate_task_spec_document) sees task {task_id} with an optional selector field set to Some(\"\") or Some(\"   \").","commonSituations":"A UI or script writing Some/default-empty into an optional field instead of omitting it; deserializing YAML with `selector: \"\"` rather than dropping the key.","solutions":["Remove the field entirely (or set it to None) if no selector is needed","Provide a non-empty selector value","Normalize empty strings to None before validation"],"exampleFix":"// before\nselector: Some(\"\")\n// after\nselector: None // or Some(\"gpu=true\")","handlingStrategy":"validation","validationCode":"fn selector_present_ok(s: Option<&str>) -> bool { s.map_or(true, |v| !v.trim().is_empty()) }","typeGuard":"fn clean_selector(s: Option<&str>) -> Option<&str> { s.filter(|v| !v.trim().is_empty()) }","tryCatchPattern":"match validate_worker_selector(task_id, \"selector\", value) { Err(e) if e.to_string().contains(\"cannot be empty\") => *value = None, r => r? }","preventionTips":["Omit the key rather than writing an empty string","Normalize \"\" to None when deserializing optional fields","Validate user form input before constructing the spec"],"tags":["validation","optional-field","fleet"],"backgroundTag":"empty-required-field","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}