windmill-labs/windmill · error
{section} dependency element: missing or invalid `name` fiel
Error message
{section} dependency element: missing or invalid `name` field What it means
Each roles/collections entry in the requirements YAML must have a `name` field that is a string. update_versions throws this when the entry is a map but lacks `name`, or its `name` value is not a plain string (e.g. an integer, boolean, or nested structure), because the name is required to look up the locked version.
Source
Thrown at backend/parsers/windmill-parser-yaml/src/lib.rs:904
for el in elements {
let Yaml::Hash(ref mut h) = el else {
return Err(anyhow!("{section} dependency element should be a map"));
};
if let Some(name) = h
.get(&Yaml::String("name".to_string()))
.and_then(|n| n.as_str())
{
if let Some(version) = versions.get(name) {
h.insert(
Yaml::String("version".to_string()),
Yaml::String(version.to_string()),
);
} else {
logs.push_str(&format!("WARNING: {section} dependency `{name}` has no locked version, using the latest or system installed version.\n"));
}
} else {
return Err(anyhow!(
"{section} dependency element: missing or invalid `name` field"
));
}
}
}
Ok(logs)
}
pub fn add_versions_to_requirements_yaml(
input: &str,
role_versions: &HashMap<String, String>,
collection_versions: &HashMap<String, String>,
) -> anyhow::Result<(String, String)> {
let mut docs =
YamlLoader::load_from_str(input).map_err(|e| anyhow!("YAML parse error: {}", e))?;
let doc = &mut docs[0];
View on GitHub (pinned to e474e8803c)
Solutions
- Add a `name:` key to every entry: `- name: community.postgresql`.
- Quote the name if it could parse as a number or boolean: `name: "123org.collection"`.
- Rename legacy `src:` keys to `name:` or restructure for this parser.
- Ensure the name value is a scalar string, not a nested map/list.
Example fix
# before
collections:
- version: 3.0.0
# after
collections:
- name: community.postgresql
version: 3.0.0 Defensive patterns
Strategy: validation
Validate before calling
fn validate_names(input: &str) -> Result<(), String> {
let doc: serde_yaml::Value = serde_yaml::from_str(input).map_err(|e| e.to_string())?;
for section in ["roles", "collections"] {
if let Some(items) = doc.get(section).and_then(|s| s.as_sequence()) {
for (i, e) in items.iter().enumerate() {
match e.get("name").map(|n| n.is_string()) {
Some(true) => {}
_ => return Err(format!("{section}[{i}] needs a string `name` field")),
}
}
}
}
Ok(())
} Type guard
fn has_string_name(v: &serde_yaml::Value) -> bool {
v.get("name").map(|n| n.is_string()).unwrap_or(false)
} Try / catch
match pin_versions(input, &roles, &collections) {
Err(e) if e.to_string().contains("missing or invalid `name`") => {
eprintln!("Add name: <dep> to every entry; quote numeric-looking names\n{e}");
}
other => other,
} Prevention
- Every entry needs `name:`; `src:`/`version:`-only entries are rejected
- Quote names that YAML might infer as numbers or booleans
- Rename legacy `src:` keys to `name:`
- Assert each entry has a string name before pinning versions
When it happens
Trigger: An entry like `- version: 1.2.3` (version without name), `- src: ...` only, or `- name: 123` where the name is numeric and YAML infers a non-string type.
Common situations: Using the `src` key (legacy git-role format) instead of `name`; copy-pasting collection entries that only carry `version`; numeric-looking collection names (e.g. org names starting with digits) parsed as integers; forgetting the name when hand-editing.
Related errors
- {section} dependency element should be a map
- Files should have a `resource` or `variable` field that will
- {section} dependency should be a map
- Failed to parse yaml: {}
- Invalid inventory definition
AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03).
Data as JSON: /api/errors/9ee5cd269d58c1d1.
Report an issue: GitHub.