{"record":{"id":"41274b0a94f8950f","repo":"abiosoft/colima","slug":"unexpected-error-during-yaml-node-traversal-doc-h","errorCode":null,"errorMessage":"unexpected error during yaml node traversal: doc has multiple children of len %d","messagePattern":"unexpected error during yaml node traversal: doc has multiple children of len (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/yamlutil/yaml.go","lineNumber":99,"sourceCode":"\t\t// nil slices are converted to untyped nil to encode as `null` instead of `[]`.\n\t\t// this preserves nil vs empty slice distinction when the yaml is loaded back.\n\t\tif v := reflect.ValueOf(val); v.Kind() == reflect.Slice && v.IsNil() {\n\t\t\tval = nil\n\t\t}\n\n\t\t// lazy way, delegate node construction to the yaml library via a roundtrip.\n\t\t// no performance concern as only one file is being read\n\t\tb, err := yaml.Marshal(val)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unexpected error nested value encoding: %w\", err)\n\t\t}\n\t\tvar newNode yaml.Node\n\t\tif err := yaml.Unmarshal(b, &newNode); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unexpected error during yaml node traversal: %w\", err)\n\t\t}\n\n\t\tif l := len(newNode.Content); l != 1 {\n\t\t\treturn nil, fmt.Errorf(\"unexpected error during yaml node traversal: doc has multiple children of len %d\", l)\n\t\t}\n\t\t*node = *newNode.Content[0]\n\t}\n\n\tb, err := encode(root)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error encoding yaml file: %w\", err)\n\t}\n\n\treturn b, nil\n}\n\nfunc traverseConfig(parentKey string, s any, vals map[string]any) {\n\ttyp := reflect.TypeOf(s)\n\tval := reflect.ValueOf(s)\n\n\t// everything else is a value, no nesting required\n\tif typ.Kind() != reflect.Struct {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/util/yamlutil/yaml.go#L81-L117","documentation":"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.","triggerScenarios":"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).","commonSituations":"Effectively none; theoretically a vendored/patched yaml.v3 diverging from upstream behavior.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := util.Save(cfg, file); err != nil {\n    if strings.Contains(err.Error(), \"multiple children\") {\n        // unreachable invariant hit: report binary/library versions upstream\n    }\n    return err\n}","preventionTips":["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"],"tags":["yaml","internal","invariant","rare"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}