{"record":{"id":"09ca09ad19169082","repo":"kubernetes/kops","slug":"error-marshaling-manifest-to-yaml-v-09ca09","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/etcdmanager/model.go","lineNumber":116,"sourceCode":"\tfor _, etcdCluster := range b.Cluster.Spec.EtcdClusters {\n\t\tbackupStore := \"\"\n\t\tif etcdCluster.Backups != nil {\n\t\t\tbackupStore = etcdCluster.Backups.BackupStore\n\t\t}\n\t\tif backupStore == \"\" {\n\t\t\treturn fmt.Errorf(\"backupStore must be set for use with etcd-manager\")\n\t\t}\n\n\t\tfor _, member := range etcdCluster.Members {\n\t\t\tinstanceGroupName := fi.ValueOf(member.InstanceGroup)\n\t\t\tmanifest, err := b.buildManifest(etcdCluster, instanceGroupName)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tmanifestYAML, err := k8scodecs.ToVersionedYaml(manifest)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error marshaling manifest to yaml: %v\", err)\n\t\t\t}\n\n\t\t\tname := fmt.Sprintf(\"%s-%s\", etcdCluster.Name, instanceGroupName)\n\t\t\tc.AddTask(&fitasks.ManagedFile{\n\t\t\t\tContents:  fi.NewBytesResource(manifestYAML),\n\t\t\t\tLifecycle: b.Lifecycle,\n\t\t\t\tLocation:  new(\"manifests/etcd/\" + name + \".yaml\"),\n\t\t\t\tName:      new(\"manifests-etcdmanager-\" + name),\n\t\t\t})\n\t\t}\n\n\t\tinfo := &etcdClusterSpec{\n\t\t\tEtcdVersion: etcdCluster.Version,\n\t\t\tMemberCount: int32(len(etcdCluster.Members)),\n\t\t}\n\n\t\td, err := json.MarshalIndent(info, \"\", \"  \")\n\t\tif err != nil {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/components/etcdmanager/model.go#L98-L134","documentation":"After building the etcd-manager Pod manifest, the builder converts it to a versioned YAML with k8scodecs.ToVersionedYaml and wraps any failure. This means the in-memory Pod object could not be serialized to YAML — a marshaling failure of a struct that is normally always serializable, so the underlying error (from %v) is the real cause.","triggerScenarios":"buildManifest produces a Pod containing values the Kubernetes codec cannot marshal (e.g. malformed typed fields, custom object injected into the manifest) during `kops update cluster`.","commonSituations":"kOps/k8s.io/api version skew where ToVersionedYaml cannot map the Pod to a registered versioned type; corrupted or patched etcd-manager template manifest; custom builds with modified Pod structs.","solutions":["Read the wrapped %v cause and fix the offending field in the etcd cluster spec / image override it points at.","Ensure kOps dependencies (k8s.io/apimachinery, k8s.io/api) are consistent: `make gomod` after dependency changes.","Upgrade or rebuild kops so the bundled etcd-manager manifest template matches the installed k8s codecs.","Run with --v=2+ to capture which manifest (bundle) failed and file an issue if it reproduces with a stock template."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := k8scodecs.ToVersionedYaml(manifest); err != nil {\n\treturn fmt.Errorf(\"manifest for %q not serializable: %w\", etcdCluster.Name, err)\n}","typeGuard":null,"tryCatchPattern":"if err := buildModel(); err != nil {\n\tif strings.Contains(err.Error(), \"error marshaling manifest to yaml\") {\n\t\t// inspect wrapped cause with --v=2 and fix the offending spec field\n\t}\n}","preventionTips":["Keep k8s.io/api and apimachinery versions aligned across the kOps module graph.","Test custom manifest overrides locally with kubectl dry-run before cluster updates.","Upgrade kops as one unit rather than cherry-picking dependencies."],"tags":["kops","etcd-manager","yaml","serialization"],"backgroundTag":"yaml-marshaling-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"}