{"record":{"id":"fcc893669c574306","repo":"windmill-labs/windmill","slug":"specified-inventory-was-missing-in-the-script-argu","errorCode":null,"errorMessage":"Specified inventory was missing in the script arguments","messagePattern":"Specified inventory was missing in the script arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/src/ansible_executor.rs","lineNumber":2255,"sourceCode":"    conn: &Connection,\n) -> error::Result<Vec<String>> {\n    let mut logs = String::new();\n    let mut nsjail_mounts: Vec<String> = vec![];\n\n    for inventory in &r.inventories {\n        let content;\n        if let Some(resource_path) = &inventory.pinned_resource {\n            content = client\n                .get_resource_value_interpolated::<serde_json::Value>(\n                    resource_path,\n                    Some(job_id.to_string()),\n                )\n                .await?;\n        } else {\n            let o = args\n                .as_ref()\n                .and_then(|g| g.get(&inventory.name))\n                .ok_or(anyhow!(\n                    \"Specified inventory was missing in the script arguments\"\n                ))?;\n\n            content = serde_json::from_str(o.get())\n                .map_err(|e| anyhow!(\"Failed to parse inventory arg: {}\", e))?;\n\n            if content == serde_json::value::Value::Null {\n                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.\"))?;\n            }\n        }\n\n        let validated_path = write_file_at_user_defined_location(\n            job_dir,\n            &inventory.name,\n            content\n                .get(\"content\")\n                .and_then(|v| v.as_str())\n                .ok_or(anyhow!(","sourceCodeStart":2237,"sourceCodeEnd":2273,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/src/ansible_executor.rs#L2237-L2273","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Provide the argument named exactly like `inventory.name` when running the script (UI form, `wmill script run --data`, flow extra_inputs).","If no inventory is wanted, delete the `inventory:` section from the script yaml instead of passing null.","Align the argument key with the inventory name after any rename.","In flows, ensure the upstream step output actually produces that key (check for null propagation)."],"exampleFix":"// before\nwmill script run ansible_job --data '{}'\n// after\nwmill script run ansible_job --data '{\"my_inventory\": {\"content\": \"[web]\\nhost1\"}}'","handlingStrategy":"validation","validationCode":"const args = JSON.parse(require('fs').readFileSync(0, 'utf8'));\nif (!('my_inventory' in args) || args.my_inventory == null) {\n  throw new Error(\"argument 'my_inventory' matching inventory.name is required\");\n}","typeGuard":"function hasInventory(args, name) {\n  return args != null && typeof args === 'object' && args[name] != null;\n}","tryCatchPattern":null,"preventionTips":["Keep argument keys in sync with inventory.name when renaming.","Fill all required inputs in the run form / scheduler config before running.","If no inventory is wanted, delete the `inventory:` yaml section rather than passing null.","In flows, assert upstream outputs are non-null before feeding them as inputs."],"tags":["ansible","inventory","missing-argument","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}