windmill-labs/windmill · error

Invalid inventory resource, `content` field absent or invali

Error message

Invalid inventory resource, `content` field absent or invalid

What it means

When the inventory comes from a resource object (content variable `content`), the executor requires a string field `content` holding the inventory text. If the object lacks `content` or it is not a string, this anyhow error is thrown. It means the resource shape does not match the expected inventory-resource schema.

Source

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

                .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!(
                    "Invalid inventory resource, `content` field absent or invalid"
                ))?,
            None,
        )
        .map_err(|e| anyhow!("Couldn't write inventory: {}", e))?;

        nsjail_mounts.push(
            define_nsjail_mount(job_dir, &validated_path)
                .map_err(|e| anyhow!("Inventory path (a.k.a. `name`) is invalid: {}", e))?,
        );

        logs.push_str(&format!("\nCreated inventory `{}`", inventory.name));
    }

    for file_res in &r.file_resources {
        let r =
            get_resource_or_variable_content(client, &file_res.resource_path, job_id.to_string())
                .await?;

View on GitHub (pinned to e474e8803c)

Solutions

  1. Open the resource in the Windmill UI and ensure it is of type `inventory` with a string `content` field.
  2. Recreate the resource via the inventory resource type so the schema is enforced.
  3. If constructing inline, pass `{"content": "<inventory JSON string>"}` with content as a string.
  4. Stringify the inventory document into `content` rather than nesting it as an object.

Example fix

// before (wrong resource shape)
{ "web": { "hosts": ["host1"] } }
// after
{ "content": "{\"web\": {\"hosts\": [\"host1\"]}}" }
Defensive patterns

Strategy: type-guard

Validate before calling

const r = getResource('u/windmill/inventory', 'my_inv');
if (typeof r?.content !== 'string') throw new Error('resource must have a string `content` field');

Type guard

function isInventoryResource(v) {
  return v != null && typeof v === 'object' && typeof v.content === 'string' && v.content.length > 0;
}

Prevention

When it happens

Trigger: An inventory resource (or inline object) passed as the inventory arg is `{}` , has `content` as a non-string (object/number), or the wrong resource type was selected, in create_file_resources via handle_ansible_job.

Common situations: Pointing the script at a generic variable/duck resource instead of an inventory resource; hand-writing the resource JSON and forgetting `content`; a resource of type `inventory` whose stored value was edited and `content` removed; nested content object pasted instead of stringified JSON.

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/ca8cfc847c3922ae. Report an issue: GitHub.