abiosoft/colima · error
unexpected error during yaml node traversal: doc has multipl
Error message
unexpected error during yaml node traversal: doc has multiple children of len %d
What it means
encodeYAML (util/yamlutil/yaml.go:99) requires the node produced by the Marshal->Unmarshal roundtrip to have exactly one child; yaml.Marshal never emits multi-document output, so Content length != 1 is an unreachable internal invariant. Like errors 295/296's sibling checks, it exists to fail loudly rather than silently mis-apply a config value to the wrong node.
Source
Thrown at util/yamlutil/yaml.go:99
// nil slices are converted to untyped nil to encode as `null` instead of `[]`.
// this preserves nil vs empty slice distinction when the yaml is loaded back.
if v := reflect.ValueOf(val); v.Kind() == reflect.Slice && v.IsNil() {
val = nil
}
// lazy way, delegate node construction to the yaml library via a roundtrip.
// no performance concern as only one file is being read
b, err := yaml.Marshal(val)
if err != nil {
return nil, fmt.Errorf("unexpected error nested value encoding: %w", err)
}
var newNode yaml.Node
if err := yaml.Unmarshal(b, &newNode); err != nil {
return nil, fmt.Errorf("unexpected error during yaml node traversal: %w", err)
}
if l := len(newNode.Content); l != 1 {
return nil, fmt.Errorf("unexpected error during yaml node traversal: doc has multiple children of len %d", l)
}
*node = *newNode.Content[0]
}
b, err := encode(root)
if err != nil {
return nil, fmt.Errorf("error encoding yaml file: %w", err)
}
return b, nil
}
func traverseConfig(parentKey string, s any, vals map[string]any) {
typ := reflect.TypeOf(s)
val := reflect.ValueOf(s)
// everything else is a value, no nesting required
if typ.Kind() != reflect.Struct {View on GitHub (pinned to c3a5f9184d)
Solutions
- Restore the stock gopkg.in/yaml.v3 dependency and rebuild
- Verify `go version -m ./colima` shows the expected module versions
- Report upstream with the reported length value for diagnosis
Defensive patterns
Strategy: try-catch
Try / catch
if err := util.Save(cfg, file); err != nil {
if strings.Contains(err.Error(), "multiple children") {
// unreachable invariant hit: report binary/library versions upstream
}
return err
} Prevention
- Use stock dependencies; `go mod tidy` before building
- Verify module versions with `go version -m` when weird internal errors appear
- Report occurrences upstream — these errors exist to detect broken builds
When it happens
Trigger: Unreachable through normal input; would require a yaml.v3 implementation whose Unmarshal into a Node produces multiple document children for single-document input (vendored fork or corrupted library).
Common situations: Effectively none; theoretically a vendored/patched yaml.v3 diverging from upstream behavior.
Related errors
- unexpected error during yaml node traversal: %w
- embedded default config is invalid yaml: %w
- unexpected error during yaml decode: doc has multiple childr
- error traversing yaml node: %w
- error encoding yaml file: %w
AI-assisted analysis of abiosoft/colima@c3a5f9184d (2026-08-15).
Data as JSON: /api/errors/41274b0a94f8950f.
Report an issue: GitHub.