Hmbown/CodeWhale · error · anyhow::Error

Automation prompt cannot be empty

Error message

Automation prompt cannot be empty

What it means

update_automation rejects a prompt update whose value trims to empty. Only Some(prompt) triggers validation; omitting the field leaves the prompt unchanged. The trimmed value is persisted and later executed.

Source

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

        Ok(out)
    }

    pub fn update_automation(
        &self,
        id: &str,
        req: UpdateAutomationRequest,
    ) -> Result<AutomationRecord> {
        let mut existing = self.get_automation(id)?;

        if let Some(name) = req.name {
            if name.trim().is_empty() {
                bail!("Automation name cannot be empty");
            }
            existing.name = name.trim().to_string();
        }
        if let Some(prompt) = req.prompt {
            if prompt.trim().is_empty() {
                bail!("Automation prompt cannot be empty");
            }
            existing.prompt = prompt.trim().to_string();
        }
        if let Some(rrule) = req.rrule {
            let normalized = rrule.trim().to_ascii_uppercase();
            AutomationSchedule::parse_rrule(&normalized)?;
            existing.rrule = normalized;
            if matches!(existing.status, AutomationStatus::Active) {
                let schedule = AutomationSchedule::parse_rrule(&existing.rrule)?;
                existing.next_run_at =
                    Some(schedule.next_after_with_anchor(Utc::now(), existing.created_at)?);
            }
        }
        if let Some(cwds) = req.cwds {
            existing.cwds = cwds;
        }
        if let Some(mode) = req.mode {
            existing.mode = normalize_optional_string(Some(mode));

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Send a non-empty prompt, or omit the field to keep the current prompt
  2. Validate trim-ness before submitting the update
  3. Default templates to a descriptive fallback string

Example fix

// before
let req = UpdateAutomationRequest { prompt: Some("  ".to_string()), ..Default::default() };

// after
let req = UpdateAutomationRequest { prompt: Some("Summarize today's incidents".to_string()), ..Default::default() };
Defensive patterns

Strategy: validation

Validate before calling

fn prompt_update_ok(prompt: &Option<String>) -> bool {
    prompt.as_deref().is_none_or(|p| !p.trim().is_empty())
}

Type guard

fn is_non_blank(s: &str) -> bool { !s.trim().is_empty() }

Prevention

When it happens

Trigger: Calling update_automation with UpdateAutomationRequest { prompt: Some(String::new()), .. } or Some("\t".into()).

Common situations: Template-rendered prompts whose variables resolve to whitespace; UIs submitting unvalidated textarea content; scripts defaulting to empty strings.

Related errors


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