zeroclaw-labs/zeroclaw · error · anyhow::Error

unsupported delay unit

Error message

unsupported delay unit '{unit}', use s/m/h/d

What it means

Validation guard in parse_delay: the unit suffix following the number is not one of s, m, h, or d. An omitted unit defaults to minutes, but an unrecognized suffix (for example '30w') reaches this match fallback and the delay string is rejected.

Solutions

  1. Use a supported delay unit: s (seconds), m (minutes), h (hours), or d (days).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/zeroclaw-runtime/src/cron/mod.rs:433 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/79d478cc816a0de8. Report an issue: GitHub.

Appendix: source

Thrown at crates/zeroclaw-runtime/src/cron/mod.rs:433

}

pub fn parse_delay(input: &str) -> Result<chrono::Duration> {
    let input = input.trim();
    if input.is_empty() {
        anyhow::bail!("delay must not be empty");
    }
    let split = input
        .find(|c: char| !c.is_ascii_digit())
        .unwrap_or(input.len());
    let (num, unit) = input.split_at(split);
    let amount: i64 = num.parse()?;
    let unit = if unit.is_empty() { "m" } else { unit };
    let duration = match unit {
        "s" => chrono::Duration::seconds(amount),
        "m" => chrono::Duration::minutes(amount),
        "h" => chrono::Duration::hours(amount),
        "d" => chrono::Duration::days(amount),
        _ => anyhow::bail!("unsupported delay unit '{unit}', use s/m/h/d"),
    };
    Ok(duration)
}

#[cfg(test)]
mod security_validation_tests {
    use super::*;
    use tempfile::TempDir;

    fn test_config(tmp: &TempDir) -> Config {
        let config = Config {
            data_dir: tmp.path().join("data"),
            config_path: tmp.path().join("config.toml"),
            ..Config::default()
        };
        std::fs::create_dir_all(&config.data_dir).unwrap();
        config
    }

View on GitHub (pinned to 88bb9c8533)