kubernetes/kops · error
parsing embedded file %q: %w
Error message
parsing embedded file %q: %w
What it means
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).
Source
Thrown at pkg/assets/assetdata/data.go:54
// If not found, it returns (nil, false, nil)
func GetHash(canonicalURL *url.URL) (*hashing.Hash, bool, error) {
var allMatches []*file
if err := fs.WalkDir(embeddedDataFS, ".", func(p string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
b, err := fs.ReadFile(embeddedDataFS, p)
if err != nil {
return fmt.Errorf("reading embedded file %q: %w", p, err)
}
manifest, err := parseManifestFile(b)
if err != nil {
return fmt.Errorf("parsing embedded file %q: %w", p, err)
}
matches := manifest.Matches(canonicalURL.String())
allMatches = append(allMatches, matches...)
return nil
}); err != nil {
return nil, false, fmt.Errorf("walking embedded data: %w", err)
}
hashes := sets.New[string]()
for _, match := range allMatches {
hashes.Insert(match.SHA256)
}
if len(hashes) == 0 {
return nil, false, nil
}
if len(hashes) > 1 {
return nil, false, fmt.Errorf("found multiple matches for asset %q", canonicalURL)View on GitHub (pinned to 4c8573c808)
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)
Example fix
// before (broken embedded manifest)
files:
- name: linux/amd64/kubelet
sha256: [not-a-string]
// after
files:
- name: linux/amd64/kubelet
sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 Defensive patterns
Strategy: validation
Validate before calling
for _, f := range embeddedYamls {
m := &assetdata.Manifest{} // hypothetical export or local mirror of struct
if err := yaml.Unmarshal(f, m); err != nil {
t.Fatalf("invalid embedded manifest: %v", err)
}
} Try / catch
h, found, err := assetdata.GetHash(u)
var parseErr error
if err != nil && errors.Unwrap(err) != nil && strings.Contains(err.Error(), "parsing embedded file") {
parseErr = err // embedded data invalid: report bug, no runtime remedy
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- error parsing addons or manifest: %v
- error parsing addons: %v
- failed to parse objects: %w
- failed to parse objects: %w
- error parsing file %q: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/7276c8f351d058df.
Report an issue: GitHub.