{"record":{"id":"ab12fae75d6a7065","repo":"kubernetes/kops","slug":"expected-pod-object-in-manifest-s-found-t","errorCode":null,"errorMessage":"expected Pod object in manifest %s, found %T","messagePattern":"expected Pod object in manifest (.+?), found %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/model/components/kubeapiserver/model.go","lineNumber":130,"sourceCode":"// buildHealthcheckSidecar builds the partial pod for the healthcheck sidecar.\n// nodeup will merge it into the kube-apiserver pod.\nfunc (b *KubeApiserverBuilder) buildHealthcheckSidecar() (*corev1.Pod, error) {\n\t// TODO: pull from bundle\n\tbundle := \"(embedded kube-apiserver-healthcheck manifest)\"\n\tmanifest := []byte(fmt.Sprintf(defaultManifest, kopsversion.KopsVersionImageTag(), wellknownports.KubeAPIServerHealthCheck))\n\n\tvar pod *corev1.Pod\n\tvar container *corev1.Container\n\t{\n\t\tobjects, err := model.ParseManifest(manifest)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif len(objects) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"expected exactly one object in manifest %s, found %d\", bundle, len(objects))\n\t\t}\n\t\tif podObject, ok := objects[0].(*corev1.Pod); !ok {\n\t\t\treturn nil, fmt.Errorf(\"expected Pod object in manifest %s, found %T\", bundle, objects[0])\n\t\t} else {\n\t\t\tpod = podObject\n\t\t}\n\n\t\tif len(pod.Spec.Containers) != 1 {\n\t\t\treturn nil, fmt.Errorf(\"expected exactly one container in etcd-manager Pod, found %d\", len(pod.Spec.Containers))\n\t\t}\n\t\tcontainer = &pod.Spec.Containers[0]\n\t}\n\n\t// Remap image via AssetBuilder\n\tcontainer.Image = b.AssetBuilder.RemapImage(container.Image)\n\n\treturn pod, nil\n}\n","sourceCodeStart":112,"sourceCodeEnd":146,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/model/components/kubeapiserver/model.go#L112-L146","documentation":"After the single-object check, buildHealthcheckSidecar type-asserts the parsed object to *corev1.Pod. If the sole object in the sidecar bundle manifest is not a Pod (e.g. a Deployment or ConfigMap), the assertion fails and this error reports the actual Go type via %T. It protects the subsequent code that directly manipulates pod.Spec fields.","triggerScenarios":"kops update cluster with a healthcheck sidecar bundle whose single YAML document defines a non-Pod kind — due to an edited/corrupted embedded bundle or a kOps build packaging the wrong file.","commonSituations":"Custom kOps builds where the sidecar bundle was accidentally replaced, or assets regenerated with the wrong template kind.","solutions":["Restore the official sidecar bundle (kind: Pod) by using an unmodified official kOps build","Change the bundle's YAML document kind to Pod if maintaining a custom bundle","Check git history of the assets/bundle directory for accidental replacements","Report upstream if official release reproduces"],"exampleFix":"// before (bundle manifest)\napiVersion: apps/v1\nkind: Deployment\n// after\napiVersion: v1\nkind: Pod","handlingStrategy":"type-guard","validationCode":"// Pre-check bundle kind before model build\nobjects, err := model.ParseManifest(bundleBytes)\nif err != nil {\n    return err\n}\nif len(objects) == 1 {\n    if _, ok := objects[0].(*corev1.Pod); !ok {\n        return fmt.Errorf(\"bundle must define a Pod, got %T\", objects[0])\n    }\n}","typeGuard":"// Narrow the parsed manifest object to a Pod\nfunc asPod(obj runtime.Object) (*corev1.Pod, bool) {\n    p, ok := obj.(*corev1.Pod)\n    return p, ok\n}","tryCatchPattern":"if err := buildManifest(); err != nil {\n    if strings.Contains(err.Error(), \"expected Pod object in manifest\") {\n        return fmt.Errorf(\"sidecar bundle kind wrong — restore kind: Pod: %w\", err)\n    }\n    return err\n}","preventionTips":["Ensure custom sidecar bundles declare kind: Pod","Diff custom bundles against upstream templates","Test bundle parsing in CI for forked kOps builds"],"tags":["kube-apiserver","healthcheck","type-assertion"],"backgroundTag":"unexpected-manifest-object-kind","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"}