windmill-labs/windmill · error

Invalid inventory definition

Error message

Invalid inventory definition

What it means

parse_additional_inventories walks the `additional_inventories` value of the Ansible requirements YAML and returns Ok only if every entry matches the expected structure (inventory as array/hash with known keys). If the value never matches any accepted shape, the function falls through to this generic error.

Source

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

                        .map(|s| s.to_string())
                        .unwrap_or_else(|| {
                            count += 1;
                            if count == 0 {
                                "Additional inventories".to_string()
                            } else {
                                format!("Additional inventories ({count})")
                            }
                        });

                    ret.push(PreexistingAnsibleInventory::PassedInArgs(
                        InventoryFilenameListDefinition { options, name },
                    ))
                }
            }
        }
        return Ok(ret);
    }
    return Err(anyhow!("Invalid inventory definition"));
}

fn parse_inventories(inventory_yaml: &Yaml) -> anyhow::Result<Vec<AnsibleInventory>> {
    if let Yaml::Array(arr) = inventory_yaml {
        let mut ret = vec![];
        for (i, inv) in arr.iter().enumerate() {
            if let Yaml::Hash(inv) = inv {
                let resource_type = inv
                    .get(&Yaml::String("resource_type".to_string()))
                    .and_then(|v| v.as_str())
                    .map(|s| s.to_string());

                let windmill_path = inv
                    .get(&Yaml::String("default".to_string()))
                    .and_then(|v| v.as_str())
                    .map(|s| s.to_string());

                let name = if i == 0 {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Ensure `additional_inventories` is an array of inventory definitions in the documented format.
  2. Check each inventory entry uses only the recognized keys (name/path/host_list etc. as supported).
  3. Validate the YAML structure against the AnsibleRequirements schema in the source.

Example fix

# before
additional_inventories: prod
# after
additional_inventories:
  - name: prod
    path: inventories/prod
Defensive patterns

Strategy: validation

Validate before calling

fn valid_additional_inventories(v: &Yaml) -> bool {
    matches!(v, Yaml::Array(items) if items.iter().all(|i| matches!(i, Yaml::Hash(_))))
}

Type guard

fn is_inventory_array(v: &Yaml) -> bool { matches!(v, Yaml::Array(_)) }

Try / catch

match parse_ansible_reqs(content) {
    Ok(r) => r,
    Err(e) if e.to_string() == "Invalid inventory definition" => {
        eprintln!("Fix additional_inventories structure: expected array of inventory objects");
        Err(e)
    }
    Err(e) => Err(e),
}

Prevention

When it happens

Trigger: Calling parse_ansible_sig or parse_ansible_reqs with `additional_inventories:` in the YAML whose content is neither a valid list of inventory entries nor of an accepted type (e.g. a bare string or scalar instead of the expected array/hash).

Common situations: Writing `additional_inventories: prod` instead of a list of inventory objects, or nesting an inventory under an unrecognized key so no branch of the match accepts it.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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