windmill-labs/windmill · error

YAML emit error: {}

Error message

YAML emit error: {}

What it means

add_versions_to_requirements_yaml in windmill-parser-yaml re-serializes a parsed YAML document after injecting version pins into the requirements. When yaml-rust's YamlEmitter::dump fails to serialize the mutated document, the error is wrapped as 'YAML emit error: {}'. This is thrown by the ansible dependency parser when it cannot emit the resulting document back to a string.

Source

Thrown at backend/parsers/windmill-parser-yaml/src/lib.rs:943

    logs.push_str(
        &update_versions("roles", doc, role_versions)
            .map_err(|e| anyhow!("Error updating role versions: {e}"))?,
    );
    logs.push_str(
        &update_versions("collections", doc, collection_versions)
            .map_err(|e| anyhow!("Error updating collection versions: {e}"))?,
    );

    if !logs.is_empty() {
        logs.push_str("WARNING: You might want to try adding manual versions for these, otherwise there could be breaking changes on deployed scripts\n");
    }

    let mut out_str = String::new();
    {
        let mut emitter = YamlEmitter::new(&mut out_str);
        emitter
            .dump(doc)
            .map_err(|e| anyhow!("YAML emit error: {}", e))?;
    }

    Ok((out_str, logs))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_parse_ansible_assets() {
        let p = r#"
---
inventory:
  - resource_type: ansible_inventory
    # You can pin an inventory to this script by hardcoding the resource path:
    # resource: u/user/your_resource
# - name: hcloud.yml

View on GitHub (pinned to e474e8803c)

Solutions

  1. Simplify the requirements YAML to standard list-of-mappings syntax (collections/roles with name/version keys)
  2. Validate the YAML with a linter (yamllint) and fix non-standard constructs like anchors or duplicate keys
  3. Pin the requirements to explicit 'name'/'version' string values instead of shorthand forms
  4. Check the windmill-yaml-parser dependency version; upgrade if the yaml-rust emitter bug was fixed

Example fix

# before (shorthand, may emit badly)
collections:
  - community.general

# after
 collections:
  - name: community.general
    version: 8.0.0
Defensive patterns

Strategy: validation

Validate before calling

// validate YAML structure before handing to parser
let doc: Yaml = serde_yaml::from_str(&req_yaml)?;
for c in doc.as_vec().ok_or("requirements must be a list")? {
    let m = c.as_hash().ok_or("each entry must be a mapping")?;
    assert!(m.contains_key(&Yaml::from_str("name")), "missing 'name' key");
}

Try / catch

match add_versions_to_requirements_yaml(&yaml) {
    Ok((out, logs)) => out,
    Err(e) if e.to_string().contains("YAML emit error") => {
        tracing::warn!("requirements YAML could not be re-emitted: {e:#}");
        fallback_to_original(yaml)
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling add_versions_to_requirements_yaml (via the ansible_dep parser path) with a requirements YAML that, after version annotation, produces a document structure the YamlEmitter cannot dump — e.g. deeply non-standard or malformed nodes introduced by parsing odd input.

Common situations: An Ansible requirements.yml with unusual syntax (anchors, tags, non-string keys) that parses but re-emits badly; corrupted requirements file contents pasted from elsewhere; upstream yaml crate changes in serialization rules.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/2c7435f62aa2b929. Report an issue: GitHub.