{"record":{"id":"d7187ef2e9d86458","repo":"kubernetes/kops","slug":"error-serializing-addons-yaml-v","errorCode":null,"errorMessage":"error serializing addons yaml: %v","messagePattern":"error serializing addons yaml: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannel.go","lineNumber":74,"sourceCode":"\taddonsObject.ObjectMeta.Name = \"bootstrap\"\n\n\tfor _, manifest := range a.addonManifests {\n\t\tif manifest.addonSpec == nil {\n\t\t\treturn fmt.Errorf(\"addon manifest %q did not have a spec\", fi.ValueOf(manifest.Name))\n\t\t}\n\t\tif manifest.addonSpec.ManifestHash == \"\" {\n\t\t\treturn fmt.Errorf(\"addon %q manifest hash was not populated\", fi.ValueOf(manifest.addonSpec.Name))\n\t\t}\n\t\taddonsObject.Spec.Addons = append(addonsObject.Spec.Addons, manifest.addonSpec)\n\t}\n\n\tif err := addonsObject.Verify(); err != nil {\n\t\treturn err\n\t}\n\n\taddonsYAML, err := utils.YamlMarshal(addonsObject)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error serializing addons yaml: %v\", err)\n\t}\n\n\ta.Contents = fi.NewBytesResource(addonsYAML)\n\treturn nil\n}\n\nfunc (a *BootstrapChannel) Find(c *fi.CloudupContext) (*BootstrapChannel, error) {\n\tmanagedFile := a.toManagedFile()\n\tactual, err := managedFile.Find(c)\n\tif err != nil || actual == nil {\n\t\treturn nil, err\n\t}\n\ta.PublicACL = managedFile.PublicACL\n\n\treturn &BootstrapChannel{\n\t\tName:      a.Name,\n\t\tLifecycle: a.Lifecycle,\n\t\tLocation:  a.Location,","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/bootstrapchannelbuilder/bootstrapchannel.go#L56-L92","documentation":"AddonManifest.Normalize verifies the addon spec and then serializes the addons object to YAML. This error is returned when utils.YamlMarshal fails on the verified addons object, meaning the in-memory addon channel object cannot be converted to YAML bytes for the manifest resource.","triggerScenarios":"Calling Normalize on an AddonManifest whose Addons object contains a value that cannot be marshaled by the YAML encoder (e.g. an unsupported/invalid field value left in the spec that passes Verify but breaks yaml marshaling).","commonSituations":"Custom or hand-edited cluster addon specs injected into the channel; a kops upgrade that changed the addons struct so previously-valid data no longer marshals; programmatic construction of AddonManifest tasks in tooling built on kops libraries.","solutions":["Inspect the wrapped %v error to identify which field failed to marshal","Remove or fix the offending field in the addon spec (kops edit cluster / addon manifest)","Upgrade kops to a version where the addons struct serializes correctly","Rebuild the addon manifest from a known-good channel spec"],"exampleFix":"// before: custom addon spec with unsupported field\naddon.Spec.Manifest = fi.PtrTo(\"weird/addon.yaml\")\n// after: use a supported manifest path and let kops render it\naddon.Spec.Manifest = fi.PtrTo(\"addons/my-addon.yaml\")","handlingStrategy":"validation","validationCode":"// Pre-validate the addon spec marshals cleanly before Normalize\nif _, err := utils.YamlMarshal(addonsObject); err != nil {\n    return fmt.Errorf(\"addon object not serializable: %w\", err)\n}\nif err := addonsObject.Verify(); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := manifest.Normalize(ctx); err != nil {\n    if strings.Contains(err.Error(), \"error serializing addons yaml\") {\n        // inspect wrapped err, fix offending addon spec field\n    }\n    return err\n}","preventionTips":["Always call Verify() and fix reported issues before Normalize","Keep addon specs to schema-defined fields","Test custom addon channels with a dry-run build before applying","Pin kops versions between state store writes"],"tags":["yaml","serialization","addons","kops"],"backgroundTag":"yaml-serialization-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"}