kubernetes/kops · warning
building yaml: %w
Error message
building yaml: %w
What it means
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.
Source
Thrown at pkg/assets/assetdata/tools/cmd/generatefileassets/main.go:107
if len(tokens) != 2 {
return fmt.Errorf("unexpected line %q (expected 2 tokens)", line)
}
hash := tokens[0]
name := tokens[1]
name = removeBadPrefix(name)
if exclude.Matches(prefix + name) {
continue
}
m.Files = append(m.Files, file{
Name: prefix + name,
SHA256: hash,
})
}
out, err := yaml.Marshal(&m)
if err != nil {
return fmt.Errorf("building yaml: %w", err)
}
if _, err := os.Stdout.Write(out); err != nil {
return fmt.Errorf("writing output: %w", err)
}
return nil
}
type manifest struct {
// FileStores []fileStore `json:"filestores,omitempty"`
Files []file `json:"files,omitempty"`
}
type file struct {
Name string `json:"name,omitempty"`
SHA256 string `json:"sha256,omitempty"`
}
// removeBadPrefix is a hack for some of the older kubernetes sha256sum files,View on GitHub (pinned to 4c8573c808)
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
Defensive patterns
Strategy: try-catch
Try / catch
out, err := yaml.Marshal(&m)
if err != nil {
// practically unreachable for this struct; report as a toolchain bug
return fmt.Errorf("building yaml: %w", err)
} Prevention
- 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
When it happens
Trigger: yaml.Marshal returns an error while converting the manifest struct to YAML — realistically only from an unsupported value or an internal marshaling failure.
Common situations: Virtually never hit by users; if seen it indicates a broken toolchain/dependency build or tampered local source.
Related errors
- error parsing addons or manifest: %v
- error parsing addons: %v
- failed to parse objects: %w
- failed to parse objects: %w
- error parsing %v: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/608936da8fa26488.
Report an issue: GitHub.