{"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":2787,"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).with_context(|| format!(\"create {}\", parent.display()))?;\n    }\n    crate::utils::write_atomic(path, &serde_json::to_vec_pretty(value)?)","sourceCodeStart":2769,"sourceCodeEnd":2805,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/automation_manager.rs#L2769-L2805","documentation":"validate_name_and_prompt requires a non-blank automation name before an automation record can be created or saved. A name that is empty or only whitespace is rejected because the name is user-facing and used to identify the automation.","triggerScenarios":"Creating or updating an automation via the API/UI with name set to \"\" or whitespace (e.g. \"   \").","commonSituations":"A form submitted without filling the name field; trimming/pasting that left only spaces; programmatic creation where the name variable was never assigned.","solutions":["Provide a non-empty, non-whitespace name when creating/updating the automation.","Add a required-field check in the UI/form so submission is blocked while name is blank.","If the name is derived from other input, fall back to a default name when it trims to empty."],"exampleFix":"// before\ncreate_automation(\"\", prompt)?;\n// after\nlet name = name.trim();\nanyhow::ensure!(!name.is_empty(), \"Automation name is required\");\ncreate_automation(name, prompt)?;","handlingStrategy":"validation","validationCode":"if name.trim().is_empty() {\n    return Err(anyhow!(\"Automation name is required\"));\n}","typeGuard":null,"tryCatchPattern":"match create_automation(&name, &prompt) {\n    Ok(rec) => show(rec),\n    Err(e) if e.to_string().contains(\"name is required\") => focus_name_field_with_error(),\n    Err(e) => return Err(e),\n}","preventionTips":["Make the name field required in UI forms with client-side validation.","Trim and check user input before passing it to creation APIs.","Provide a sensible default name when deriving one from optional input."],"tags":["validation","automation","input"],"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"}