{"record":{"id":"326abf7b2ca79599","repo":"Hmbown/CodeWhale","slug":"kind-must-not-be-empty","errorCode":null,"errorMessage":"{kind} must not be empty","messagePattern":"(.+?) must not be empty","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/automation_manager.rs","lineNumber":1834,"sourceCode":"fn read_run_file(path: &Path) -> Result<AutomationRunRecord> {\n    let raw =\n        fs::read_to_string(path).with_context(|| format!(\"Failed to read {}\", path.display()))?;\n    let run: AutomationRunRecord = serde_json::from_str(&raw)\n        .with_context(|| format!(\"Failed to parse {}\", path.display()))?;\n    if run.schema_version > CURRENT_RUN_SCHEMA_VERSION {\n        bail!(\n            \"Automation run schema v{} is newer than supported v{}\",\n            run.schema_version,\n            CURRENT_RUN_SCHEMA_VERSION\n        );\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> {","sourceCodeStart":1816,"sourceCodeEnd":1852,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/0c42157ee52f9d55af2b506d71b46249910f77d3/crates/tui/src/automation_manager.rs#L1816-L1852","documentation":"ensure_safe_storage_id validates identifiers that become file names under the automation and task storage trees. It splits the value as a path and bails with '{kind} must not be empty' when the string yields zero path components — an empty id. The {kind} placeholder names the exact field at the call site: 'automation id', 'trigger id', 'run id', or 'task id'.","triggerScenarios":"Saving or addressing an automation, trigger, run, or task with an empty id string — e.g. a record built with an uninitialized or trimmed-to-empty id passed to the save/get/delete entry points that call ensure_safe_storage_id (automation_manager.rs lines ~920-949).","commonSituations":"Struct literals with placeholder ids (String::new()) reaching a save path; ids derived from user-supplied names that were blank; an upstream id generator returning empty and the failure being swallowed before the store call.","solutions":["Populate the id before the call — generate a uuid or slug at record creation time.","If the id derives from a user-entered name, validate the name is non-empty before building the record.","Use the {kind} text in the message to identify exactly which field was empty."],"exampleFix":"// before\nlet record = DelayedTriggerRecord {\n    trigger_id: String::new(), // never populated\n    // ..remaining fields\n};\nmanager.save_trigger(&record)?; // bails: trigger id must not be empty\n\n// after\nlet record = DelayedTriggerRecord {\n    trigger_id: uuid::Uuid::new_v4().simple().to_string(),\n    // ..remaining fields\n};\nmanager.save_trigger(&record)?;","handlingStrategy":"validation","validationCode":"fn non_empty_storage_id(id: &str) -> bool {\n    !id.trim().is_empty()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate ids at record construction; never default them to empty.","Add required-field checks in the UI/CLI before persistence calls.","Fail loudly when an id generator returns empty instead of propagating it."],"tags":["rust","validation","storage-id","automation"],"backgroundTag":"empty-required-field","analyzedSha":"0c42157ee52f9d55af2b506d71b46249910f77d3","analyzedAt":"2026-08-20T21:50:45.477Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}