windmill-labs/windmill · error

Invalid value for `mode` permissions property on targeted fi

Error message

Invalid value for `mode` permissions property on targeted file to: {}, err: {e}

What it means

parse_file_resource throws this when the `mode` key of a file entry is a YAML integer that cannot fit into u32 (e.g. a negative number or an out-of-range i64 value). The integer branch does `i64 -> u32` conversion and wraps any failure with this message, which includes the file's target path and the underlying conversion error.

Source

Thrown at backend/parsers/windmill-parser-yaml/src/lib.rs:795

    max_count
}

fn parse_file_resource(yaml: &Yaml) -> anyhow::Result<FileResource> {
    if let Yaml::Hash(f) = yaml {
        let target_path = f
            .get(&Yaml::String("target".to_string()))
            .and_then(|x| x.as_str())
            .map(|x| x.to_string())
            .ok_or(anyhow!(
                "No `target` provided for the file. Please input a target path (only relative paths are allowed) where the ansible playbook can read this file.",
            ))?;

        let mut mode = None;
        if let Some(u) = f.get(&Yaml::String("mode".to_string())) {
            let mode_val: u32 = match u {
                Yaml::Integer(u) => {
                    u.clone().try_into().map_err(|e| {
                        anyhow!(
                            "Invalid value for `mode` permissions property on targeted file to: {}, err: {e}",
                            target_path
                        )
                    })?
                }
                Yaml::String(s) => {
                    let val = if s.starts_with("0b") {
                        u32::from_str_radix(&s[2..], 2)
                    } else if s.starts_with("0o") {
                        u32::from_str_radix(&s[2..], 8)
                    } else if s.starts_with("0") {
                        u32::from_str_radix(&s[1..], 8)
                    } else {
                        u32::from_str_radix(s, 8)
                    };

                    val.map_err(|e| anyhow!("Error parsing permission mode value {s}: {e}"))?
                }

View on GitHub (pinned to e474e8803c)

Solutions

  1. Use a valid permission value within 0o0..0o777 (e.g. `mode: 0o644`)
  2. Remove any negative sign from the mode value
  3. If writing decimal, keep it <= 511 (the decimal equivalent of 0o777)
  4. Quote octal strings with the 0o prefix as an alternative (`mode: '0o644'`)

Example fix

# before
- resource: my_script
  target: script.sh
  mode: -644

# after
- resource: my_script
  target: script.sh
  mode: 0o644
Defensive patterns

Strategy: validation

Validate before calling

fn validate_mode_int(mode: i64) -> Result<u32, String> {
    let m = u32::try_from(mode).map_err(|_| format!("mode {} is negative or overflows u32", mode))?;
    if m <= 0o777 { Ok(m) } else { Err(format!("mode {m} exceeds 0o777; use an octal literal like 0o644")) }
}

Type guard

fn is_valid_mode(v: &Yaml) -> bool {
    match v {
        Yaml::Integer(i) => *i >= 0 && *i <= 0o777,
        Yaml::String(s) => u32::from_str_radix(s.trim_start_matches("0o").trim_start_matches("0"), 8).map(|m| m <= 0o777).unwrap_or(false),
        _ => false,
    }
}

Prevention

When it happens

Trigger: A file entry has `mode` as Yaml::Integer whose value is negative or exceeds u32::MAX (e.g. `mode: -1` or an absurdly large number), so `try_into::<u32>()` fails.

Common situations: Writing a negative mode by sign typo; pasting a decimal that overflows; confusing octal notation and entering an enormous value; YAML parsing an unquoted large literal as i64.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/8caa34563ce325e6. Report an issue: GitHub.