Hmbown/CodeWhale · error · anyhow::Error

Failed to parse ONCE AT

Error message

Failed to parse ONCE AT '{trimmed}'. Use local YYYY-MM-DDTHH:MM[:SS] or RFC3339

What it means

parse_once_at accepts either an RFC3339 timestamp or a local NaiveDateTime in YYYY-MM-DDTHH:MM[:SS] form. If the trimmed string matches neither RFC3339 nor either local format, it bails with this message echoing the input and the expected shapes. This is parse-level rejection at schedule creation, distinct from the 'does not exist' error for DST-gap times that did parse.

Solutions

  1. Supply the time as YYYY-MM-DDTHH:MM or YYYY-MM-DDTHH:MM:SS (local time), e.g. 2026-09-21T09:00.
  2. Or use a full RFC3339 timestamp with offset, e.g. 2026-09-21T09:00:00Z or 2026-09-21T09:00:00+02:00.
  3. Use 'T' (not a space or slash) between date and time, and a 4-digit year with 2-digit month/day.

Example fix

// before
FREQ=ONCE;AT=tomorrow 9am
// after
FREQ=ONCE;AT=2026-09-22T09:00
Defensive patterns

Strategy: validation

Validate before calling

fn valid_once_at(s: &str) -> bool {
    let t = s.trim();
    chrono::DateTime::parse_from_rfc3339(t).is_ok()
        || chrono::NaiveDateTime::parse_from_str(t, "%Y-%m-%dT%H:%M:%S").is_ok()
        || chrono::NaiveDateTime::parse_from_str(t, "%Y-%m-%dT%H:%M").is_ok()
}

Try / catch

match AutomationSchedule::parse(rrule) {
    Ok(s) => save(s),
    Err(e) if e.to_string().contains("Failed to parse ONCE AT") => show_format_help(&e),
    Err(e) => report(e),
}

Prevention

When it happens

Trigger: AutomationSchedule::parse with FREQ=ONCE;AT=<value> where the value is not RFC3339 and not YYYY-MM-DDTHH:MM or YYYY-MM-DDTHH:MM[:SS] — e.g. 'tomorrow 9am', '2026/09/21 09:00', epoch seconds, or a missing date part.

Common situations: Users typing human-friendly times ('9am tomorrow'); using slashes or a space instead of 'T'; omitting the date; locale-formatted dates.

Understand the failure class

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/4e85b66b7a7c3653. Report an issue: GitHub.

Appendix: source

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

        .filter(|value| !value.is_empty())
        .ok_or_else(|| anyhow::anyhow!("CRON schedules require EXPR"))?;
    ParsedCronExpr::parse(&expr)?;
    Ok(AutomationSchedule::Cron { expr })
}

fn parse_once_at(raw: &str) -> Result<DateTime<Utc>> {
    let trimmed = raw.trim();
    if let Ok(at) = DateTime::parse_from_rfc3339(trimmed) {
        return Ok(at.with_timezone(&Utc));
    }
    for format in ["%Y-%m-%dT%H:%M:%S", "%Y-%m-%dT%H:%M"] {
        if let Ok(naive) = NaiveDateTime::parse_from_str(trimmed, format) {
            return resolve_local_datetime(&Local, naive)
                .map(|value| value.with_timezone(&Utc))
                .ok_or_else(|| anyhow::anyhow!("ONCE local time does not exist: {trimmed}"));
        }
    }
    bail!("Failed to parse ONCE AT '{trimmed}'. Use local YYYY-MM-DDTHH:MM[:SS] or RFC3339")
}

#[derive(Debug, Clone)]
struct ParsedCronExpr {
    minute: CronField,
    hour: CronField,
    day_of_month: CronField,
    month: CronField,
    day_of_week: CronField,
}

impl ParsedCronExpr {
    fn parse(expr: &str) -> Result<Self> {
        let fields: Vec<&str> = expr.split_whitespace().collect();
        if fields.len() != 5 {
            bail!(
                "CRON EXPR must have exactly 5 fields: minute hour day-of-month month day-of-week"
            );

View on GitHub (pinned to 73e0f67d83)