{"record":{"id":"4fed601fe27846a3","repo":"abiosoft/colima","slug":"embedded-default-config-is-invalid-yaml-w","errorCode":null,"errorMessage":"embedded default config is invalid yaml: %w","messagePattern":"embedded default config is invalid yaml: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/yamlutil/yaml.go","lineNumber":48,"sourceCode":"\t\treturn err\n\t}\n\tif err := os.WriteFile(file, b, 0644); err != nil {\n\t\treturn fmt.Errorf(\"error writing yaml file: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc encodeYAML(conf config.Config) ([]byte, error) {\n\tvar doc yaml.Node\n\n\tf, err := embedded.Read(\"defaults/colima.yaml\")\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error reading config file: %w\", err)\n\t}\n\n\tif err := yaml.Unmarshal(f, &doc); err != nil {\n\t\treturn nil, fmt.Errorf(\"embedded default config is invalid yaml: %w\", err)\n\t}\n\n\tif l := len(doc.Content); l != 1 {\n\t\treturn nil, fmt.Errorf(\"unexpected error during yaml decode: doc has multiple children of len %d\", l)\n\t}\n\troot := doc.Content[0]\n\n\t// get all nodes\n\tnodeVals := map[string]*yaml.Node{}\n\tif err := traverseNode(\"\", root, nodeVals); err != nil {\n\t\treturn nil, fmt.Errorf(\"error traversing yaml node: %w\", err)\n\t}\n\n\t// get all node values\n\tstructVals := map[string]any{}\n\ttraverseConfig(\"\", conf, structVals)\n\n\t// apply values to nodes","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/abiosoft/colima/blob/c3a5f9184d83a197184f897a9f07eb3c01b3bc88/util/yamlutil/yaml.go#L30-L66","documentation":"encodeYAML (util/yamlutil/yaml.go:48) unmarshals the embedded defaults/colima.yaml into a yaml.Node; failure means the asset bytes are not valid YAML (tabs for indentation, unclosed quotes, bad anchors). Because the file ships inside the binary and is YAML-validated in the stock repo, hitting this means the embedded content in your binary was corrupted or hand-edited into invalid YAML — an internal invariant, not a runtime condition.","triggerScenarios":"A fork edit to embedded/defaults/colima.yaml introduced invalid YAML (e.g. a tab, an unterminated string) and the binary was rebuilt; a corrupted embedded FS produced garbage bytes.","commonSituations":"Fork maintainers tweaking default settings directly in the embedded template; merge conflicts resolved badly in the defaults file; encoding changes (BOM, CRLF) introduced by editors breaking strict YAML.","solutions":["Validate the file locally: `python -c 'import yaml,sys; yaml.safe_load(open(\"embedded/defaults/colima.yaml\"))'` or any YAML linter, then fix the syntax error it reports","Revert local edits to embedded/defaults/colima.yaml and change defaults via colima's config layer instead","Reinstall the stock binary if you did not build it yourself","Add a CI test that yaml.Unmarshal's the embedded asset on every commit"],"exampleFix":"# embedded/defaults/colima.yaml (before) — tab indentation breaks YAML\nvm:\n\tcpu: 4\n\n# after\nvm:\n  cpu: 4","handlingStrategy":"fallback","validationCode":"// CI guard for forks: embedded defaults must stay valid YAML\nfunc TestEmbeddedDefaultsAreValidYAML(t *testing.T) {\n    b, err := embedded.Read(\"defaults/colima.yaml\")\n    if err != nil { t.Fatal(err) }\n    var doc yaml.Node\n    if err := yaml.Unmarshal(b, &doc); err != nil { t.Fatalf(\"defaults broken: %v\", err) }\n}","typeGuard":null,"tryCatchPattern":"if err := util.Save(cfg, file); err != nil {\n    if strings.Contains(err.Error(), \"invalid yaml\") {\n        // the binary's embedded asset is corrupt: reinstall, don't retry\n        return fmt.Errorf(\"colima binary corrupted — reinstall: %w\", err)\n    }\n    return err\n}","preventionTips":["Never hand-edit embedded/defaults/colima.yaml without a YAML lint step","Change defaults through colima's config layer, not the embedded file","Use spaces (never tabs) in embedded YAML","Run the round-trip Save() test in CI"],"tags":["yaml","embedded","corruption","internal"],"backgroundTag":null,"analyzedSha":"c3a5f9184d83a197184f897a9f07eb3c01b3bc88","analyzedAt":"2026-08-15T18:58:08.334Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}