Hmbown/CodeWhale · error · anyhow::Error

CRON {field_name} field contains an empty list item

Error message

CRON {field_name} field contains an empty list item

What it means

A comma-separated cron field contained an empty list item: each part is trimmed and checked for emptiness before range/step parsing. '1,,3', a trailing comma '1,2,', or a leading ',1' in any of the five fields triggers it.

Source

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

#[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 {
                (part, 1)
            };

            let range = if base == "*" {
                (min, max)
            } else if let Some((start, end)) = base.split_once('-') {
                let start = parse_cron_atom(start.trim(), min, max, names, field_name)?;

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Remove empty items: '1,3' not '1,,3'
  2. Strip trailing/leading commas before submitting
  3. When generating lists, filter out empty strings before joining with ','
  4. Dry-run the full EXPR via parse_rrule

Example fix

// before
rrule = "FREQ=CRON;EXPR=0 0 12 1,,3 *"

// after
rrule = "FREQ=CRON;EXPR=0 0 12 1,3 *"
Defensive patterns

Strategy: validation

Validate before calling

fn cron_list_items_nonempty(expr: &str) -> bool {
    expr.split_whitespace()
        .all(|field| field.split(',').all(|item| !item.trim().is_empty()))
}

Prevention

When it happens

Trigger: EXPR='0 0 12 1,,3 *'; EXPR='0 9-17 * * 1,'; templated lists where a filter removed an element and left an empty slot between commas.

Common situations: Programmatically built comma lists with a trailing comma; join of an array that contains empty strings; simple typos.

Related errors


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