abiosoft/colima · error
unexpected error during yaml decode: doc has multiple childr
Error message
unexpected error during yaml decode: doc has multiple children of len %d
What it means
encodeYAML (util/yamlutil/yaml.go:52) requires the unmarshaled document node to have exactly one child — the root mapping. A yaml.Node document with multiple Content children means the source YAML contained multiple documents separated by '---'. yaml.v3's Unmarshal into a single Node tolerates multi-document input, so colima defends here by rejecting it before traversal; the embedded default is a single document, so this fires only when that invariant is broken.
Source
Thrown at util/yamlutil/yaml.go:52
}
return nil
}
func encodeYAML(conf config.Config) ([]byte, error) {
var doc yaml.Node
f, err := embedded.Read("defaults/colima.yaml")
if err != nil {
return nil, fmt.Errorf("error reading config file: %w", err)
}
if err := yaml.Unmarshal(f, &doc); err != nil {
return nil, fmt.Errorf("embedded default config is invalid yaml: %w", err)
}
if l := len(doc.Content); l != 1 {
return nil, fmt.Errorf("unexpected error during yaml decode: doc has multiple children of len %d", l)
}
root := doc.Content[0]
// get all nodes
nodeVals := map[string]*yaml.Node{}
if err := traverseNode("", root, nodeVals); err != nil {
return nil, fmt.Errorf("error traversing yaml node: %w", err)
}
// get all node values
structVals := map[string]any{}
traverseConfig("", conf, structVals)
// apply values to nodes
for key, node := range nodeVals {
val := structVals[key]
// top level, ignore. except known maps.View on GitHub (pinned to c3a5f9184d)
Solutions
- Remove '---' separators from embedded/defaults/colima.yaml so it is exactly one document
- If multiple documents are truly needed, split the file and read only the first document explicitly
- Add a lint step rejecting multi-document content in the embedded defaults
- Revert to the stock embedded file and layer changes through colima's config instead
Example fix
# embedded/defaults/colima.yaml (before) — two documents vm: cpu: 4 --- mounts: [] # after — single document vm: cpu: 4 mounts: []
Defensive patterns
Strategy: fallback
Validate before calling
// reject multi-document YAML before it reaches encodeYAML
func isSingleDocument(b []byte) bool {
d := yaml.NewDecoder(bytes.NewReader(b))
var v any
if err := d.Decode(&v); err != nil { return false }
return d.Decode(&v) == io.EOF
} Try / catch
if err := util.Save(cfg, file); err != nil {
if strings.Contains(err.Error(), "multiple children") {
// embedded template gained '---' separators: reinstall or fix the asset
return fmt.Errorf("colima defaults corrupted (multi-doc) — reinstall: %w", err)
}
return err
} Prevention
- Keep embedded YAML single-document; no '---' separators
- Use a YAML linter that flags multi-doc in assets meant to be single-doc
- In forks, add the single-document test to CI
When it happens
Trigger: An embedded/defaults/colima.yaml that gained a '---' document separator (e.g. concatenated files), producing doc.Content of length 2+.
Common situations: Fork merges that concatenate snippets onto the defaults file; tooling that appends generated YAML with a leading ---; copy-paste of multi-document Kubernetes-style YAML into the defaults template.
Related errors
- embedded default config is invalid yaml: %w
- error traversing yaml node: %w
- error reading config file: %w
- unexpected error during yaml node traversal: %w
- unexpected error during yaml node traversal: doc has multipl
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/5a5343cb154d070b.
Report an issue: GitHub.