windmill-labs/windmill · error

Failed to parse yaml: {}

Error message

Failed to parse yaml: {}

What it means

parse_ansible_sig parses the Ansible script's inner content as YAML before extracting its signature (delegate_to_git_repo and arguments). The YamlLoader failed to parse the content, so the function returns this error wrapping the underlying serde-yaml message.

Source

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

use anyhow::anyhow;
use serde::Serialize;
use serde_json::json;
use windmill_parser::{Arg, MainArgSignature, ObjectProperty, ObjectType, Typ};
use yaml_rust::{Yaml, YamlEmitter, YamlLoader};

pub mod asset_parser;
pub use asset_parser::parse_assets;

pub mod dbt;
pub use dbt::{
    dbt_arg_schema, default_command as default_dbt_command, parse_dbt_descriptor, parse_dbt_sig,
    DbtDescriptor, DbtEngine, DbtTestBehavior, DBT_COMMANDS, DBT_COMMAND_ARG, DBT_COMMAND_LABEL,
    DBT_DEFAULT_WAREHOUSE,
};

pub fn parse_ansible_sig(inner_content: &str) -> anyhow::Result<MainArgSignature> {
    let docs = YamlLoader::load_from_str(inner_content)
        .map_err(|e| anyhow!("Failed to parse yaml: {}", e))?;

    let mut delegating_to_git_repo = false;
    if let Yaml::Hash(doc) = &docs[0] {
        if let Some(v) = doc.get(&Yaml::String("delegate_to_git_repo".to_string())) {
            delegating_to_git_repo = extract_delegate_to_git_repo_details(v).is_some();
        }
    }

    if docs.len() < 2 && !delegating_to_git_repo {
        return Ok(MainArgSignature {
            star_args: false,
            star_kwargs: false,
            args: vec![],
            auto_kind: None,
            has_preprocessor: None,
            ..Default::default()
        });
    }

View on GitHub (pinned to e474e8803c)

Solutions

  1. Read the wrapped serde-yaml message for the exact line/column and fix the YAML syntax (typically indentation).
  2. Replace tab characters with spaces.
  3. Validate the YAML with a linter (e.g. yamllint) before deploying.
  4. Ensure the document is a mapping at the root, since the code indexes docs[0] as a Hash.

Example fix

# before
debuilder_to_git_repo:
  repo: x
    bad_indent
# after
delegate_to_git_repo:
  repo: x
Defensive patterns

Strategy: try-catch

Validate before calling

if let Err(e) = serde_yml::from_str::<serde_yml::Value>(content) { /* surface e before calling parse_ansible_sig */ }

Type guard

fn is_mapping_root(docs: &[Yaml]) -> bool { matches!(docs.first(), Some(Yaml::Hash(_))) }

Try / catch

match parse_ansible_sig(content) {
    Ok(sig) => sig,
    Err(e) if e.to_string().starts_with("Failed to parse yaml") => {
        eprintln!("Fix YAML syntax: {e}");
        return Err(e);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Any call to parse_ansible_sig whose inner_content is not valid YAML — malformed indentation, bad types, tabs, duplicate keys, or an unclosed block — triggers the map_err on YamlLoader::load_from_str.

Common situations: Editing an Ansible windmill script in the UI and breaking indentation with spaces/tabs, pasting YAML with template syntax that breaks parsing, or trailing content after the document.

Understand the failure class

Related errors


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