tinyhumansai/openhuman · error

delay must not be empty

Error message

delay must not be empty

What it means

parse_human_delay trims its input and rejects an empty string before splitting number from unit. An empty delay has no meaning; without the guard the split/parse would surface as a confusing integer-parse error instead.

Source

Thrown at src/openhuman/cron/ops.rs:134

        }
    }

    let patch = CronJobPatch {
        schedule,
        command,
        name,
        ..CronJobPatch::default()
    };

    update_job(config, id, patch)
}

/// Parse a human-friendly delay string (e.g. "5m", "2h", "30s") into a
/// `chrono::Duration`. Defaults to minutes when no unit is given.
pub fn parse_human_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)
}

pub async fn cron_list(config: &Config) -> Result<RpcOutcome<Vec<CronJob>>, String> {

View on GitHub (pinned to 7491200858)

Solutions

  1. Pass a concrete delay: 30s, 5m, 2h, 1d (unit defaults to minutes when omitted)
  2. Treat empty as 'no delay' upstream — skip the call or apply a default before invoking
  3. In shell wrappers use ${DELAY:-5m} so an unset variable never reaches the CLI

Example fix

# before
DELAY=""; openhuman cron once --delay "$DELAY" prompt.txt

# after
DELAY="${DELAY:-5m}"; openhuman cron once --delay "$DELAY" prompt.txt
Defensive patterns

Strategy: validation

Validate before calling

fn parseable_delay(s: &str) -> bool {
    let t = s.trim();
    !t.is_empty() && t.start_with(|c: char| c.is_ascii_digit())
}

Type guard

function isValidDelay(input: string): boolean {
  const t = input.trim();
  return t.length > 0 && /^\d/.test(t);
}

Prevention

When it happens

Trigger: CLI `openhuman cron once --delay ""` or a whitespace-only value; RPC callers forwarding an unvalidated empty form field; scripts passing an unset shell variable that expands to an empty argument.

Common situations: Optional form field submitted blank; env var referenced but never exported; quoting like "$DELAY" with DELAY unset passing '' through.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@7491200858 (2026-08-17). Data as JSON: /api/errors/611968e1cf1fb978. Report an issue: GitHub.