windmill-labs/windmill · error

Specified inventory was missing in the script arguments

Error message

Specified inventory was missing in the script arguments

What it means

When an ansible script declares an inventory without a bundled resource (`else` branch of create_file_resources), the executor looks up the inventory's `name` key in the job's arguments object. If the argument is absent, this anyhow error aborts the job. It means the script yaml demands an inventory value the caller never supplied.

Source

Thrown at backend/windmill-worker/src/ansible_executor.rs:2255

    conn: &Connection,
) -> error::Result<Vec<String>> {
    let mut logs = String::new();
    let mut nsjail_mounts: Vec<String> = vec![];

    for inventory in &r.inventories {
        let content;
        if let Some(resource_path) = &inventory.pinned_resource {
            content = client
                .get_resource_value_interpolated::<serde_json::Value>(
                    resource_path,
                    Some(job_id.to_string()),
                )
                .await?;
        } else {
            let o = args
                .as_ref()
                .and_then(|g| g.get(&inventory.name))
                .ok_or(anyhow!(
                    "Specified inventory was missing in the script arguments"
                ))?;

            content = serde_json::from_str(o.get())
                .map_err(|e| anyhow!("Failed to parse inventory arg: {}", e))?;

            if content == serde_json::value::Value::Null {
                Err(anyhow!("The inventory argument was left empty. If you do not wish to specify an inventory for this script, remove the `inventory:` section from the yaml."))?;
            }
        }

        let validated_path = write_file_at_user_defined_location(
            job_dir,
            &inventory.name,
            content
                .get("content")
                .and_then(|v| v.as_str())
                .ok_or(anyhow!(

View on GitHub (pinned to e474e8803c)

Solutions

  1. Provide the argument named exactly like `inventory.name` when running the script (UI form, `wmill script run --data`, flow extra_inputs).
  2. If no inventory is wanted, delete the `inventory:` section from the script yaml instead of passing null.
  3. Align the argument key with the inventory name after any rename.
  4. In flows, ensure the upstream step output actually produces that key (check for null propagation).

Example fix

// before
wmill script run ansible_job --data '{}'
// after
wmill script run ansible_job --data '{"my_inventory": {"content": "[web]\nhost1"}}'
Defensive patterns

Strategy: validation

Validate before calling

const args = JSON.parse(require('fs').readFileSync(0, 'utf8'));
if (!('my_inventory' in args) || args.my_inventory == null) {
  throw new Error("argument 'my_inventory' matching inventory.name is required");
}

Type guard

function hasInventory(args, name) {
  return args != null && typeof args === 'object' && args[name] != null;
}

Prevention

When it happens

Trigger: Ansible script yaml has `inventory: { name: X }` but the run's `args` object either has no key `X` or has `X` set to null (get() returns None), in create_file_resources via handle_ansible_job.

Common situations: Scheduling/triggering the script without filling required inputs; renaming the inventory name in yaml but not the argument key; a flow passing extra_inputs missing that field; the caller passing null for an optional-looking arg.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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