kubernetes/kops · error

walking embedded data: %w

Error message

walking embedded data: %w

What it means

GetHash wraps any error returned by fs.WalkDir over the embedded manifest filesystem — including errors from its own per-file callbacks (reading/parsing) — with this message. It is the outermost wrapper for a failure while traversing the embedded asset data, so the inner %w reveals the actual cause.

Source

Thrown at pkg/assets/assetdata/data.go:61

		}
		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)
	}
	h, err := hashing.FromString(hashes.UnsortedList()[0])
	if err != nil {
		return nil, false, err
	}
	return h, true, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Read the full wrapped error chain (%w) to find the root cause file and inner error
  2. Rebuild the binary from a clean source checkout (go clean -cache && make kops)
  3. Regenerate any edited manifests with tools/cmd/generatefileassets
  4. If a real file is missing from the embed set, confirm //go:embed *.yaml covers it and rebuild

Example fix

// before: error only
err // walking embedded data: parsing embedded file "foo.yaml": ...
// after: verify manifests in-tree before building
go test ./pkg/assets/assetdata/...   # runs TestGetHash
Defensive patterns

Strategy: try-catch

Try / catch

h, found, err := assetdata.GetHash(u)
if err != nil {
	if strings.HasPrefix(err.Error(), "walking embedded data:") {
		// inspect errors.Unwrap chain for the root cause, then rebuild binary
	}
	return err
}

Prevention

When it happens

Trigger: Calling assetdata.GetHash when the embedded walk fails: an embedded file cannot be read (error 800) or its YAML cannot be parsed (error 801), or WalkDir itself hits an fs error.

Common situations: Corrupted build artifacts; invalid embedded YAML from a bad generation run; diagnosing the failure by reading the chained error message.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/3eef53e9ffca7a02. Report an issue: GitHub.