{"record":{"id":"7276c8f351d058df","repo":"kubernetes/kops","slug":"parsing-embedded-file-q-w","errorCode":null,"errorMessage":"parsing embedded file %q: %w","messagePattern":"parsing embedded file %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/assets/assetdata/data.go","lineNumber":54,"sourceCode":"// If not found, it returns (nil, false, nil)\nfunc GetHash(canonicalURL *url.URL) (*hashing.Hash, bool, error) {\n\tvar allMatches []*file\n\n\tif err := fs.WalkDir(embeddedDataFS, \".\", func(p string, d fs.DirEntry, err error) error {\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif d.IsDir() {\n\t\t\treturn nil\n\t\t}\n\t\tb, err := fs.ReadFile(embeddedDataFS, p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"reading embedded file %q: %w\", p, err)\n\t\t}\n\n\t\tmanifest, err := parseManifestFile(b)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"parsing embedded file %q: %w\", p, err)\n\t\t}\n\n\t\tmatches := manifest.Matches(canonicalURL.String())\n\t\tallMatches = append(allMatches, matches...)\n\t\treturn nil\n\t}); err != nil {\n\t\treturn nil, false, fmt.Errorf(\"walking embedded data: %w\", err)\n\t}\n\n\thashes := sets.New[string]()\n\tfor _, match := range allMatches {\n\t\thashes.Insert(match.SHA256)\n\t}\n\tif len(hashes) == 0 {\n\t\treturn nil, false, nil\n\t}\n\tif len(hashes) > 1 {\n\t\treturn nil, false, fmt.Errorf(\"found multiple matches for asset %q\", canonicalURL)","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/assets/assetdata/data.go#L36-L72","documentation":"GetHash parses each embedded YAML manifest with parseManifestFile, which unmarshals via sigs.k8s.io/yaml into a manifest struct. This error wraps a YAML unmarshal failure for one of the embedded manifest files. It means the embedded data shipped in the binary is not valid YAML of the expected shape (filestores/files entries).","triggerScenarios":"Calling assetdata.GetHash when an embedded *.yaml file fails yaml.Unmarshal — malformed YAML, wrong indentation, or a field type not matching the manifest struct (e.g. sha256 as a non-string).","commonSituations":"Running a hand-built binary after editing the embedded manifests manually; a bad code-generation run produced invalid YAML; merge conflict markers left inside an embedded manifest.","solutions":["Inspect the embedded manifest named in the error and fix its YAML syntax or field types","Regenerate the manifests with the generatefileassets tool instead of hand-editing","Rebuild the binary from a clean checkout without merge-conflict markers in *.yaml","Validate manifests before commit: sigs.k8s.io/yaml round-trip or a unit test calling GetHash (TestGetHash)"],"exampleFix":"// before (broken embedded manifest)\nfiles:\n  - name: linux/amd64/kubelet\n    sha256: [not-a-string]\n// after\nfiles:\n  - name: linux/amd64/kubelet\n    sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","handlingStrategy":"validation","validationCode":"for _, f := range embeddedYamls {\n\tm := &assetdata.Manifest{} // hypothetical export or local mirror of struct\n\tif err := yaml.Unmarshal(f, m); err != nil {\n\t\tt.Fatalf(\"invalid embedded manifest: %v\", err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"h, found, err := assetdata.GetHash(u)\nvar parseErr error\nif err != nil && errors.Unwrap(err) != nil && strings.Contains(err.Error(), \"parsing embedded file\") {\n\tparseErr = err // embedded data invalid: report bug, no runtime remedy\n}","preventionTips":["Validate all embedded YAML manifests in unit tests before release","Regenerate manifests only via tools/cmd/generatefileassets","Block merge commits containing conflict markers in *.yaml","Keep sha256 fields as plain scalar strings in manifests"],"tags":["yaml","embedded-files","parsing"],"backgroundTag":"yaml-unmarshal-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"}