Hmbown/CodeWhale · error · anyhow::Error
Automation prompt is required
Error message
Automation prompt is required
What it means
The second half of validate_name_and_prompt: an automation's prompt must contain non-whitespace content after trimming. The prompt is the instruction the automation will execute, so a blank one is refused before the record is saved.
Source
Thrown at crates/tui/src/automation_manager.rs:1847
}
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()))?;
}
let content = serde_json::to_string_pretty(value)?;
let tmp = path.with_extension("json.tmp");
fs::write(&tmp, content).with_context(|| format!("Failed to write {}", tmp.display()))?;View on GitHub (pinned to 0c42157ee5)
Solutions
- Provide a real prompt describing what the automation should do.
- Validate the prompt (trim + non-empty) at the form/CLI boundary.
- If the prompt comes from a template, fail loudly when rendering produces only whitespace.
Example fix
// before
let record = manager.create_automation(CreateAutomationRequest {
name: name.to_string(),
prompt: " ".to_string(), // blank after trim -> bails
})?;
// after
let prompt = rendered_prompt.trim();
anyhow::ensure!(!prompt.is_empty(), "Prompt 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_prompt(prompt: &str) -> bool {
!prompt.trim().is_empty()
} Prevention
- Fail loudly when prompt templates render to only whitespace.
- Require non-empty prompt text in the UI before submit.
- Keep pre-submit validation for name and prompt together so they cannot drift.
When it happens
Trigger: Calling create_automation with req.prompt set to "" or whitespace-only — e.g. a template variable that expanded to nothing, or a textarea submitted empty.
Common situations: Prompt templates with unfilled placeholders; forms where the prompt step was skipped; copy-paste of invisible whitespace characters.
Related errors
- Automation name is required
- Automation name cannot be empty
- Automation prompt cannot be empty
- {kind} must not be empty
- Speech model cannot be empty
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/fbf4ea0f14791e5f.
Report an issue: GitHub.