Hmbown/CodeWhale · error · anyhow::Error

Automation name is required

Error message

Automation name is required

What it means

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.

Source

Thrown at crates/tui/src/automation_manager.rs:1844

        );
    }
    Ok(run)
}

fn ensure_safe_storage_id(kind: &str, value: &str) -> Result<()> {
    let mut components = Path::new(value).components();
    let Some(component) = components.next() else {
        bail!("{kind} must not be empty");
    };
    if components.next().is_some() || !matches!(component, std::path::Component::Normal(_)) {
        bail!("{kind} must be a single path component");
    }
    Ok(())
}

fn validate_name_and_prompt(name: &str, prompt: &str) -> Result<()> {
    if name.trim().is_empty() {
        bail!("Automation name is required");
    }
    if prompt.trim().is_empty() {
        bail!("Automation prompt is required");
    }
    Ok(())
}

fn normalize_optional_string(value: Option<String>) -> Option<String> {
    value
        .map(|value| value.trim().to_string())
        .filter(|value| !value.is_empty())
}

fn write_json_atomic<T: Serialize>(path: &Path, value: &T) -> Result<()> {
    if let Some(parent) = path.parent() {
        fs::create_dir_all(parent)
            .with_context(|| format!("Failed to create {}", parent.display()))?;
    }

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Supply a non-blank name — any non-whitespace content counts after trimming.
  2. Add a required-field check in the UI/CLI before calling create_automation.
  3. Trim input at the boundary so whitespace-only values fail visibly and early.

Example fix

// before
let record = manager.create_automation(CreateAutomationRequest {
    name: "   ".to_string(), // blank after trim -> bails
    prompt: prompt.to_string(),
})?;

// after
let name = user_name.trim();
anyhow::ensure!(!name.is_empty(), "Name cannot be blank");
let record = manager.create_automation(CreateAutomationRequest {
    name: name.to_string(),
    prompt: prompt.to_string(),
})?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_automation_name(name: &str) -> bool {
    !name.trim().is_empty()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/42c9a881a9ab4c29. Report an issue: GitHub.