Hmbown/CodeWhale · error · anyhow::Error
CRON {field_name} field must not be empty
Error message
CRON {field_name} field must not be empty What it means
CronField::parse bails when a whole field trims to the empty string. Because ParsedCronExpr::parse splits EXPR with split_whitespace, fields can never be empty on the public path; the guard exists for direct CronField::parse calls (tests, internal callers) with '' or whitespace-only input.
Source
Thrown at crates/tui/src/automation_manager.rs:723
if valid {
Ok(())
} else {
bail!("CRON EXPR day-of-month/month combination can never occur")
}
}
}
#[derive(Debug, Clone)]
struct CronField {
values: Vec<u32>,
is_wildcard: bool,
}
impl CronField {
fn parse(raw: &str, min: u32, max: u32, names: CronNameMap, field_name: &str) -> Result<Self> {
let trimmed = raw.trim();
if trimmed.is_empty() {
bail!("CRON {field_name} field must not be empty");
}
let mut values = Vec::new();
let is_wildcard = trimmed == "*";
for part in trimmed.split(',') {
let part = part.trim();
if part.is_empty() {
bail!("CRON {field_name} field contains an empty list item");
}
let (base, step) = if let Some((base, step)) = part.split_once('/') {
let step = step
.trim()
.parse::<u32>()
.with_context(|| format!("Failed to parse CRON {field_name} step"))?;
if step == 0 {
bail!("CRON {field_name} step must be >= 1");
}
(base.trim(), step)
} else {View on GitHub (pinned to 0c42157ee5)
Solutions
- Treat as an internal invariant: check for empty fields before calling CronField::parse
- Route all expressions through ParsedCronExpr::parse or parse_rrule
- Report a bug if this surfaces from a public API entry point
Defensive patterns
Strategy: validation
Validate before calling
fn has_no_empty_cron_field(expr: &str) -> bool {
expr.split_whitespace().all(|f| !f.trim().is_empty())
} Prevention
- Use parse_rrule as the single entry point for EXPR validation
- Never hand untrimmed fields to CronField::parse directly
- Treat this error as an internal invariant violation and report it upstream
When it happens
Trigger: Only reachable by invoking CronField::parse directly with an empty or whitespace-only field string; the public rrule/EXPR path cannot produce an empty field after whitespace splitting.
Common situations: Internal tests or future refactors calling CronField::parse directly; not a user-facing failure mode.
Related errors
- Unsupported RRULE field '{key}' for CRON. Allowed: FREQ,EXPR
- CRON EXPR must have exactly 5 fields: minute hour day-of-mon
- CRON EXPR day-of-month/month combination can never occur
- CRON {field_name} field contains an empty list item
- CRON {field_name} step must be >= 1
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/c9fff1ce3361f106.
Report an issue: GitHub.