{"record":{"id":"1faac971b8739919","repo":"windmill-labs/windmill","slug":"couldn-t-write-inventory","errorCode":null,"errorMessage":"Couldn't write inventory: {}","messagePattern":"Couldn't write inventory: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/windmill-worker/src/ansible_executor.rs","lineNumber":2278,"sourceCode":"                .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!(\n                    \"Invalid inventory resource, `content` field absent or invalid\"\n                ))?,\n            None,\n        )\n        .map_err(|e| anyhow!(\"Couldn't write inventory: {}\", e))?;\n\n        nsjail_mounts.push(\n            define_nsjail_mount(job_dir, &validated_path)\n                .map_err(|e| anyhow!(\"Inventory path (a.k.a. `name`) is invalid: {}\", e))?,\n        );\n\n        logs.push_str(&format!(\"\\nCreated inventory `{}`\", inventory.name));\n    }\n\n    for file_res in &r.file_resources {\n        let r =\n            get_resource_or_variable_content(client, &file_res.resource_path, job_id.to_string())\n                .await?;\n        let path = file_res.target_path.clone();\n        let validated_path =\n            write_file_at_user_defined_location(job_dir, path.as_str(), &r, file_res.mode)\n                .map_err(|e| anyhow!(\"Couldn't write text file at {}: {}\", path, e))?;\n","sourceCodeStart":2260,"sourceCodeEnd":2296,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/windmill-worker/src/ansible_executor.rs#L2260-L2296","documentation":"write_file_at_user_defined_location failed while persisting the inventory file into the job directory; the executor wraps the io/path error with this message. Failure here usually means the filename derived from inventory.name is unusable (illegal characters, too long) or a filesystem-level error occurred in the job dir.","triggerScenarios":"create_file_resources calls write_file_at_user_defined_location(job_dir, &inventory.name, content, None) and it errors — bad path chars in `inventory.name` (slashes, `..`), permission issues on the worker's temp dir, or disk full — via handle_ansible_job.","commonSituations":"Inventory name containing `/`, spaces, or unusual unicode; name exceeding filesystem filename limits; worker tmpfs full; read-only job directory after a mount misconfiguration.","solutions":["Rename the inventory `name` in the yaml to a simple filesystem-safe identifier (letters, digits, `-`, `_`).","Check worker disk space (`df` on the job/tmp dir) and permissions of the job directory.","Look at the inner error in this message to distinguish path validation vs I/O failure.","Retry the job once disk/permission issues are fixed."],"exampleFix":"// before\ninventory: { name: \"prod/web servers\" }\n// after\ninventory: { name: \"prod-web-servers\" }","handlingStrategy":"validation","validationCode":"function isFilenameSafe(name) {\n  return /^[A-Za-z0-9._-]+$/.test(name) && !name.includes('..');\n}\nif (!isFilenameSafe(inventoryName)) throw new Error('inventory name must be a flat safe filename');","typeGuard":"function isSafeFilename(s) { return typeof s === 'string' && /^[A-Za-z0-9._-]{1,128}$/.test(s); }","tryCatchPattern":"// surface the inner io error and fail fast\nmatch write_inventory().await {\n    Err(e) if e.to_string().contains(\"Couldn't write inventory\") => bail!(\"check worker disk space and inventory name: {e}\"),\n    other => other,\n}","preventionTips":["Use letters/digits/`-`/`_` for inventory names; avoid spaces, slashes, unicode.","Keep names short (filesystem 255-byte filename limit).","Monitor worker tmp/disk usage; full disks break job dir writes.","Retry after transient disk/permission fixes."],"tags":["ansible","filesystem","inventory","io"],"backgroundTag":"file-write-failed","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"}