{"record":{"id":"608936da8fa26488","repo":"kubernetes/kops","slug":"building-yaml-w","errorCode":null,"errorMessage":"building yaml: %w","messagePattern":"building yaml: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/assets/assetdata/tools/cmd/generatefileassets/main.go","lineNumber":107,"sourceCode":"\t\tif len(tokens) != 2 {\n\t\t\treturn fmt.Errorf(\"unexpected line %q (expected 2 tokens)\", line)\n\t\t}\n\t\thash := tokens[0]\n\t\tname := tokens[1]\n\t\tname = removeBadPrefix(name)\n\n\t\tif exclude.Matches(prefix + name) {\n\t\t\tcontinue\n\t\t}\n\t\tm.Files = append(m.Files, file{\n\t\t\tName:   prefix + name,\n\t\t\tSHA256: hash,\n\t\t})\n\t}\n\n\tout, err := yaml.Marshal(&m)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"building yaml: %w\", err)\n\t}\n\tif _, err := os.Stdout.Write(out); err != nil {\n\t\treturn fmt.Errorf(\"writing output: %w\", err)\n\t}\n\treturn nil\n}\n\ntype manifest struct {\n\t// FileStores []fileStore `json:\"filestores,omitempty\"`\n\tFiles []file `json:\"files,omitempty\"`\n}\n\ntype file struct {\n\tName   string `json:\"name,omitempty\"`\n\tSHA256 string `json:\"sha256,omitempty\"`\n}\n\n// removeBadPrefix is a hack for some of the older kubernetes sha256sum files,","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/assetdata/tools/cmd/generatefileassets/main.go#L89-L125","documentation":"After parsing all lines into a manifest, run() serializes it with yaml.Marshal (sigs.k8s.io/yaml) for output. A failure here is essentially impossible for this fixed struct in practice, but it is wrapped defensively as 'building yaml' before writing to stdout.","triggerScenarios":"yaml.Marshal returns an error while converting the manifest struct to YAML — realistically only from an unsupported value or an internal marshaling failure.","commonSituations":"Virtually never hit by users; if seen it indicates a broken toolchain/dependency build or tampered local source.","solutions":["Rebuild the tool with a clean module cache: go clean -modcache && go build ./pkg/assets/assetdata/tools/cmd/generatefileassets","Verify sigs.k8s.io/yaml dependency integrity (go mod verify)","Report a bug with the wrapped inner error if it reproduces on a clean build"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := yaml.Marshal(&m)\nif err != nil {\n\t// practically unreachable for this struct; report as a toolchain bug\n\treturn fmt.Errorf(\"building yaml: %w\", err)\n}","preventionTips":["Keep the manifest struct composed of plain string fields and slices","Pin/verify sigs.k8s.io/yaml (go mod verify)","Rebuild the tool from a clean checkout if marshal errors appear","Treat any occurrence as a bug report, not a user error"],"tags":["yaml","marshaling","code-generation"],"backgroundTag":"yaml-marshal-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}