{"record":{"id":"2f62c9270974c992","repo":"windmill-labs/windmill","slug":"error-updating-collection-versions-e","errorCode":null,"errorMessage":"Error updating collection versions: {e}","messagePattern":"Error updating collection versions: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/parsers/windmill-parser-yaml/src/lib.rs","lineNumber":931,"sourceCode":"\npub fn add_versions_to_requirements_yaml(\n    input: &str,\n    role_versions: &HashMap<String, String>,\n    collection_versions: &HashMap<String, String>,\n) -> anyhow::Result<(String, String)> {\n    let mut docs =\n        YamlLoader::load_from_str(input).map_err(|e| anyhow!(\"YAML parse error: {}\", e))?;\n    let doc = &mut docs[0];\n\n    let mut logs = String::new();\n\n    logs.push_str(\n        &update_versions(\"roles\", doc, role_versions)\n            .map_err(|e| anyhow!(\"Error updating role versions: {e}\"))?,\n    );\n    logs.push_str(\n        &update_versions(\"collections\", doc, collection_versions)\n            .map_err(|e| anyhow!(\"Error updating collection versions: {e}\"))?,\n    );\n\n    if !logs.is_empty() {\n        logs.push_str(\"WARNING: You might want to try adding manual versions for these, otherwise there could be breaking changes on deployed scripts\\n\");\n    }\n\n    let mut out_str = String::new();\n    {\n        let mut emitter = YamlEmitter::new(&mut out_str);\n        emitter\n            .dump(doc)\n            .map_err(|e| anyhow!(\"YAML emit error: {}\", e))?;\n    }\n\n    Ok((out_str, logs))\n}\n\n#[cfg(test)]","sourceCodeStart":913,"sourceCodeEnd":949,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-yaml/src/lib.rs#L913-L949","documentation":"After pinning `roles`, add_versions_to_requirements_yaml pins the `collections` section and wraps any update_versions failure with 'Error updating collection versions:'. The inner cause is the same family: root not a map, a collection entry not a map, or a missing/non-string `name`. The wrapper identifies the failing section as collections.","triggerScenarios":"Calling add_versions_to_requirements_yaml where the collections array contains bare strings (`- community.postgresql`), entries without a `name` field, or the document root is not a mapping at all.","commonSituations":"Collections written in short form (ansible-galaxy accepts them, this parser does not); entries with only `version:`; names parsed as non-strings (numeric collection names); hand-edited sections dropping the name key.","solutions":["Read the inner message after the prefix to find the exact structural fault.","Ensure every collections entry is `- name: <fqcn>` with an optional `version:`.","Quote names that YAML could infer as numbers/booleans.","Validate the requirements file structure before deploy."],"exampleFix":"# before\ncollections:\n  - community.postgresql\n# after\ncollections:\n  - name: community.postgresql\n    version: 3.0.0","handlingStrategy":"validation","validationCode":"fn validate_collections(input: &str) -> Result<(), String> {\n    let doc: serde_yaml::Value = serde_yaml::from_str(input).map_err(|e| e.to_string())?;\n    let root = doc.as_mapping().ok_or(\"root must be a map\")?;\n    if let Some(items) = root.get(\"collections\").and_then(|s| s.as_sequence()) {\n        for e in items {\n            if e.get(\"name\").map(|n| n.is_string()) != Some(true) {\n                return Err(\"each collection needs a string name\".into());\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":"fn collections_are_pinnable(v: &serde_yaml::Value) -> bool {\n    v.as_mapping().map(|m| m.get(\"collections\").map(|c| c.as_sequence().map(|s| s.iter().all(|e| e.get(\"name\").map(|n| n.is_string()).unwrap_or(false)).unwrap_or(true))).unwrap_or(true)).unwrap_or(false)\n}","tryCatchPattern":"match pin_versions(input, &roles, &collections) {\n    Err(e) if e.to_string().contains(\"Error updating collection versions\") => {\n        eprintln!(\"Collections section invalid (see inner message): entries need name fields\\n{e}\");\n    }\n    other => other,\n}","preventionTips":["Write collections in long form: - name: community.postgresql, version: x.y.z","Every collection entry needs a string `name:` field","Quote collection names that could parse as numbers","Pre-validate the collections section before deploying"],"tags":["ansible","requirements","collections","version-pinning"],"backgroundTag":"invalid-dependency-manifest-entry","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"}