{"record":{"id":"d03ed86af5605d99","repo":"windmill-labs/windmill","slug":"section-dependency-should-be-a-map","errorCode":null,"errorMessage":"{section} dependency should be a map","messagePattern":"(.+?) dependency should be a map","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-yaml/src/lib.rs","lineNumber":882,"sourceCode":"        }\n        Yaml::String(s) => serde_json::Value::String(s.to_string()),\n        Yaml::Integer(i) => serde_json::Value::Number(i.clone().into()),\n        Yaml::Real(r) => serde_json::Value::Number(r.parse().unwrap_or(0.into())),\n        Yaml::Boolean(b) => serde_json::Value::Bool(*b),\n        Yaml::Null => serde_json::Value::Null,\n        _ => serde_json::Value::Null,\n    }\n}\n\nfn update_versions(\n    section: &str,\n    yaml: &mut Yaml,\n    versions: &HashMap<String, String>,\n) -> anyhow::Result<String> {\n    let mut logs = String::new();\n\n    let Yaml::Hash(ref mut m) = yaml else {\n        return Err(anyhow!(\"{section} dependency should be a map\"));\n    };\n\n    if let Some(Yaml::Array(elements)) = m.get_mut(&Yaml::String(section.to_string())) {\n        for el in elements {\n            let Yaml::Hash(ref mut h) = el else {\n                return Err(anyhow!(\"{section} dependency element should be a map\"));\n            };\n\n            if let Some(name) = h\n                .get(&Yaml::String(\"name\".to_string()))\n                .and_then(|n| n.as_str())\n            {\n                if let Some(version) = versions.get(name) {\n                    h.insert(\n                        Yaml::String(\"version\".to_string()),\n                        Yaml::String(version.to_string()),\n                    );\n                } else {","sourceCodeStart":864,"sourceCodeEnd":900,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-yaml/src/lib.rs#L864-L900","documentation":"add_versions_to_requirements_yaml pins role/collection versions into an Ansible requirements file. update_versions first asserts the top-level parsed YAML document is a mapping. This error is thrown when the requirements YAML root is not a map — e.g. it is a list at the top level, a scalar, or an empty document — so the `roles`/`collections` sections cannot be looked up.","triggerScenarios":"Calling add_versions_to_requirements_yaml with input whose first YAML document is `[]`, a plain string, or empty; legacy requirements files that are a top-level list (`- src: ...`) rather than `roles:`/`collections:` maps.","commonSituations":"Old-style ansible-galaxy requirements.yml (pre-2.10) with a top-level sequence of roles; an empty requirements file created by scaffolding; a YAML parse producing a scalar due to bad indentation.","solutions":["Restructure the requirements file as a map with `roles:` and `collections:` keys, each holding a list of {name, version} entries.","If the file is empty, add at least `roles: []` / `collections: []`.","Convert legacy top-level-list requirements to the modern map format supported by ansible-galaxy 2.10+.","Validate the parsed root is a mapping before calling the API."],"exampleFix":"# before (legacy top-level list)\n- src: geerlingguy.docker\n# after\nroles:\n  - name: geerlingguy.docker\n    version: 6.1.0","handlingStrategy":"type-guard","validationCode":"fn validate_requirements_root(input: &str) -> Result<(), String> {\n    let doc: serde_yaml::Value = serde_yaml::from_str(input).map_err(|e| e.to_string())?;\n    if doc.as_mapping().is_none() {\n        return Err(\"requirements.yml root must be a mapping with roles:/collections: keys\".into());\n    }\n    Ok(())\n}","typeGuard":"fn is_requirements_map(v: &serde_yaml::Value) -> bool {\n    v.as_mapping().map(|m| m.contains_key(\"roles\") || m.contains_key(\"collections\")).unwrap_or(false)\n}","tryCatchPattern":"match pin_versions(input, &roles, &collections) {\n    Err(e) if e.to_string().contains(\"dependency should be a map\") => {\n        eprintln!(\"requirements.yml root must be a map: roles:\\n  - name: ...\\n{e}\");\n    }\n    other => other,\n}","preventionTips":["Use the modern requirements format: root map with roles:/collections: keys","Never ship an empty or legacy top-level-list requirements file to this parser","Check the parsed root type before calling the API","Migrate ansible-galaxy <2.10 list-style requirements files"],"tags":["yaml","ansible","requirements","structure"],"backgroundTag":"invalid-yaml-structure","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"}