{"record":{"id":"6ca5fd19b81450fc","repo":"abiosoft/colima","slug":"unexpected-error-during-yaml-node-traversal-w","errorCode":null,"errorMessage":"unexpected error during yaml node traversal: %w","messagePattern":"unexpected error during yaml node traversal: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/yamlutil/yaml.go","lineNumber":95,"sourceCode":"\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\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)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/util/yamlutil/yaml.go#L77-L113","documentation":"encodeYAML (util/yamlutil/yaml.go:95) roundtrips each value: bytes just produced by yaml.Marshal are immediately Unmarshaled into a yaml.Node; this error wraps that Unmarshal. Since the input is output of the same yaml.v3 library, this failure is effectively an unreachable internal invariant — it would require Marshal to emit invalid YAML. Encountering it points to memory corruption or an inconsistent yaml.v3 version mismatch in the build.","triggerScenarios":"No legitimate runtime input reaches this line; only a corrupted process, a patched/incompatible gopkg.in/yaml.v3 replacement, or a bug in a vendored fork of the yaml library triggers it.","commonSituations":"Vendored forks of yaml.v3 with divergent behavior; binary corruption; experimental reflect-based value mutation happening concurrently during config save (data race producing garbage bytes).","solutions":["Rebuild with the stock gopkg.in/yaml.v3 dependency (go mod tidy, remove vendored forks)","Report upstream — include the wrapped underlying error, which identifies what yaml rejected","If it flaps intermittently, check for concurrent config mutation and guard saves with a mutex","Reinstall the official binary to rule out local corruption"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := util.Save(cfg, file); err != nil {\n    if strings.Contains(err.Error(), \"yaml node traversal\") {\n        // internal invariant: capture diagnostics, then reinstall/report upstream\n    }\n    return err\n}","preventionTips":["Pin gopkg.in/yaml.v3 to the version colima builds with","Avoid vendored forks of the yaml library","Keep config saves single-threaded (mutex) to rule out data races"],"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"}