wasmerio/wasmer · error

Invalid job trigger '{s}'. Must be 'pre-deployment', 'post-d

Error message

Invalid job trigger '{s}'. Must be 'pre-deployment', 'post-deployment', a valid cron expression such as '0 */5 * * *' or a duration such as '15m'.

What it means

FromStr for the job trigger enum in lib/config/src/app/job.rs accepts only 'pre-deployment', 'post-deployment', a valid cron expression (parsed as CronExpression), or a duration (parsed as PrettyDuration). If the string matches none of these, this error lists all four accepted forms. It is thrown while parsing job trigger config values from app configuration.

Source

Thrown at lib/config/src/app/job.rs:192

    }
}

impl FromStr for JobTrigger {
    type Err = anyhow::Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        if s == "pre-deployment" {
            Ok(Self::PreDeployment)
        } else if s == "post-deployment" {
            Ok(Self::PostDeployment)
        } else {
            match s.parse::<CronExpression>() {
                Ok(expr) => Ok(Self::Cron(expr)),
                _ => {
                    if let Ok(duration) = s.parse::<PrettyDuration>() {
                        Ok(Self::Duration(duration))
                    } else {
                        Err(anyhow!(
                            "Invalid job trigger '{s}'. Must be 'pre-deployment', 'post-deployment', \
                a valid cron expression such as '0 */5 * * *' or a duration such as '15m'.",
                        ))
                    }
                }
            }
        }
    }
}

impl FromStr for CronExpression {
    type Err = Box<dyn std::error::Error + Send + Sync>;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        if let Some(predefined_sched) = s.strip_prefix('@') {
            match predefined_sched {
                "hourly" => Ok(Self {
                    cron: "0 * * * *".parse().unwrap(),

View on GitHub (pinned to 8c4b9ee9d3)

Solutions

  1. Use exactly 'pre-deployment' or 'post-deployment' for the built-in hooks (lowercase, hyphenated).
  2. Write a full 5-field cron expression, e.g. '0 */5 * * *' instead of '*/5'.
  3. Use a recognized duration form such as '15m', '1h', '30s'.
  4. Trim surrounding whitespace/quotes from the value in your config file.
  5. Verify cron syntax with a validator (crontab.guru) before retrying.

Example fix

// before
let trigger: JobTrigger = "every 5 minutes".parse()?;
// after
let trigger: JobTrigger = "15m".parse()?; // or "0 */5 * * *"
Defensive patterns

Strategy: validation

Validate before calling

// validate trigger string before parsing into JobTrigger
fn validate_trigger(s: &str) -> Result<(), String> {
    let s = s.trim();
    if matches!(s, "pre-deployment" | "post-deployment") { return Ok(()); }
    let fields = s.split_whitespace().count();
    if fields == 5 { return Ok(()); } // full cron form
    if s.chars().all(|c| c.is_ascii_digit())
        && s.ends_with(|c: char| "smhd".contains(c)) { return Ok(()); } // duration form
    Err(format!("invalid trigger '{s}': use pre-deployment, post-deployment, cron '0 */5 * * *', or '15m'"))
}

Try / catch

match "every 5 minutes".parse::<JobTrigger>() {
    Ok(t) => t,
    Err(e) if e.to_string().contains("Invalid job trigger") => {
        eprintln!("{e}\nHint: cron needs 5 fields, e.g. '*/5 * * * *'");
        std::process::exit(1);
    }
    Err(e) => panic!("unexpected parse error: {e}"),
}

Prevention

When it happens

Trigger: Parsing a `[dependencies]`/jobs trigger string like "every 5 minutes", "*/5", "0 */5" (incomplete cron with missing field), "15mins", or a misspelled literal like "pre-deploy" via JobTrigger::from_str.

Common situations: Typo in 'pre-deployment'/'post-deployment'; cron written with too few fields (needs all five: minute hour dom mon dow); duration units not recognized (e.g. '90s' vs expected forms like '15m'); quotes or whitespace included in the config value.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01). Data as JSON: /api/errors/6f050c518bca5ef8. Report an issue: GitHub.