{"record":{"id":"622e6dde0adc119c","repo":"kubernetes/kops","slug":"error-marshaling-manifest-to-yaml-v-622e6d","errorCode":null,"errorMessage":"error marshaling manifest to yaml: %v","messagePattern":"error marshaling manifest to yaml: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/components/kubeapiserver/model.go","lineNumber":52,"sourceCode":"type KubeApiserverBuilder struct {\n\t*model.KopsModelContext\n\tLifecycle    fi.Lifecycle\n\tAssetBuilder *assets.AssetBuilder\n}\n\nvar _ fi.CloudupModelBuilder = &KubeApiserverBuilder{}\n\n// Build creates the tasks relating to kube-apiserver\n// Currently we only build the kube-apiserver-healthcheck sidecar\nfunc (b *KubeApiserverBuilder) Build(c *fi.CloudupModelBuilderContext) error {\n\tmanifest, err := b.buildManifest()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tmanifestYAML, err := k8scodecs.ToVersionedYaml(manifest)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error marshaling manifest to yaml: %v\", err)\n\t}\n\n\tkey := \"kube-apiserver-healthcheck\"\n\tlocation := \"manifests/static/\" + key + \".yaml\"\n\n\tc.AddTask(&fitasks.ManagedFile{\n\t\tContents:  fi.NewBytesResource(manifestYAML),\n\t\tLifecycle: b.Lifecycle,\n\t\tLocation:  new(location),\n\t\tName:      new(\"manifests-static-\" + key),\n\t})\n\n\tb.AssetBuilder.AddStaticManifest(&assets.StaticManifest{\n\t\tKey:      key,\n\t\tPath:     location,\n\t\tContents: manifestYAML,\n\t\tRoles:    []kops.InstanceGroupRole{kops.InstanceGroupRoleControlPlane, kops.InstanceGroupRoleAPIServer},\n\t})","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/components/kubeapiserver/model.go#L34-L70","documentation":"The kube-apiserver model builds the kube-apiserver-healthcheck static pod manifest and converts it to versioned YAML via k8scodecs.ToVersionedYaml. If that marshaling fails, the model build aborts with \"error marshaling manifest to yaml\". This would only occur if the generated in-memory object cannot be encoded against any versioned scheme (internal inconsistency, invalid field values).","triggerScenarios":"kops update cluster reaching the kube-apiserver model's Build with a manifest containing fields the codec rejects — typically a kOps internal bug or invalid spec values that leak into the healthcheck pod.","commonSituations":"Hit during kOps upgrades when component templates change, or with exotic cluster specs that produce invalid pod fields.","solutions":["Read the inner %v error to identify the offending field, then fix that field in the cluster spec","Upgrade kOps to the latest release; this is usually an internal encoding bug fixed upstream","Validate the cluster spec with `kops toolbox template` / dry-run to isolate the bad value","File an upstream issue with the cluster spec if reproducible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Caller wrapping the kube-apiserver model build\nif err := model.Build(ctx); err != nil {\n    if strings.Contains(err.Error(), \"error marshaling manifest to yaml\") {\n        return fmt.Errorf(\"healthcheck manifest encode failed — inspect cluster spec values: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep kOps current; encoding failures are usually upstream bugs","Avoid exotic resource quantities/field values in the cluster spec","Capture the inner %v error text when reporting issues"],"tags":["kube-apiserver","yaml","manifest"],"backgroundTag":"manifest-yaml-marshal-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"}