{"record":{"id":"42c9a881a9ab4c29","repo":"Hmbown/CodeWhale","slug":"automation-name-is-required","errorCode":null,"errorMessage":"Automation name is required","messagePattern":"Automation name is required","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":1844,"sourceCode":"        );\n    }\n    Ok(run)\n}\n\nfn ensure_safe_storage_id(kind: &str, value: &str) -> Result<()> {\n    let mut components = Path::new(value).components();\n    let Some(component) = components.next() else {\n        bail!(\"{kind} must not be empty\");\n    };\n    if components.next().is_some() || !matches!(component, std::path::Component::Normal(_)) {\n        bail!(\"{kind} must be a single path component\");\n    }\n    Ok(())\n}\n\nfn validate_name_and_prompt(name: &str, prompt: &str) -> Result<()> {\n    if name.trim().is_empty() {\n        bail!(\"Automation name is required\");\n    }\n    if prompt.trim().is_empty() {\n        bail!(\"Automation prompt is required\");\n    }\n    Ok(())\n}\n\nfn normalize_optional_string(value: Option<String>) -> Option<String> {\n    value\n        .map(|value| value.trim().to_string())\n        .filter(|value| !value.is_empty())\n}\n\nfn write_json_atomic<T: Serialize>(path: &Path, value: &T) -> Result<()> {\n    if let Some(parent) = path.parent() {\n        fs::create_dir_all(parent)\n            .with_context(|| format!(\"Failed to create {}\", parent.display()))?;\n    }","sourceCodeStart":1826,"sourceCodeEnd":1862,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/automation_manager.rs#L1826-L1862","documentation":"create_automation runs validate_name_and_prompt before persisting and rejects names that are empty after trimming. Automation records are user-facing and addressed by name, so a blank name is refused at the API boundary rather than stored.","triggerScenarios":"Calling AutomationManager::create_automation (or the update path that shares the validator) with req.name set to \"\", \"   \", or any string that is whitespace-only after trim.","commonSituations":"A form or CLI invocation submitted without a name; whitespace-only input passing a naive length check; a script defaulting the name to an empty string.","solutions":["Supply a non-blank name — any non-whitespace content counts after trimming.","Add a required-field check in the UI/CLI before calling create_automation.","Trim input at the boundary so whitespace-only values fail visibly and early."],"exampleFix":"// before\nlet record = manager.create_automation(CreateAutomationRequest {\n    name: \"   \".to_string(), // blank after trim -> bails\n    prompt: prompt.to_string(),\n})?;\n\n// after\nlet name = user_name.trim();\nanyhow::ensure!(!name.is_empty(), \"Name cannot be blank\");\nlet record = manager.create_automation(CreateAutomationRequest {\n    name: name.to_string(),\n    prompt: prompt.to_string(),\n})?;","handlingStrategy":"validation","validationCode":"fn valid_automation_name(name: &str) -> bool {\n    !name.trim().is_empty()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Mark the name field required in forms and reject whitespace-only input client-side.","Trim at the input boundary so blank values fail visibly.","Pre-validate CreateAutomationRequest fields in one place before calling the manager."],"tags":["rust","validation","automation","required-field"],"backgroundTag":"empty-required-field","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}