{"record":{"id":"33fdbd585fdac571","repo":"kubernetes/kops","slug":"failed-to-find-kind-in-object","errorCode":null,"errorMessage":"failed to find kind in object","messagePattern":"failed to find kind in object","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/pkg/channels/prune.go","lineNumber":59,"sourceCode":"\n\tif spec == nil {\n\t\treturn nil\n\t}\n\n\tobjects, err := kubemanifest.LoadObjectsFrom(manifest)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to parse objects: %w\", err)\n\t}\n\n\tobjectsByKind := make(map[schema.GroupKind][]*kubemanifest.Object)\n\tfor _, object := range objects {\n\t\tgv, err := schema.ParseGroupVersion(object.APIVersion())\n\t\tif err != nil || gv.Version == \"\" {\n\t\t\treturn fmt.Errorf(\"failed to parse apiVersion %q\", object.APIVersion())\n\t\t}\n\t\tkind := object.Kind()\n\t\tif kind == \"\" {\n\t\t\treturn fmt.Errorf(\"failed to find kind in object\")\n\t\t}\n\n\t\tgvk := gv.WithKind(kind)\n\t\tgk := gvk.GroupKind()\n\t\tobjectsByKind[gk] = append(objectsByKind[gk], object)\n\t}\n\n\tfor i := range spec.Kinds {\n\t\tpruneKind := &spec.Kinds[i]\n\t\tgk := schema.GroupKind{Group: pruneKind.Group, Kind: pruneKind.Kind}\n\t\tif err := p.pruneObjectsOfKind(ctx, gk, pruneKind, objectsByKind[gk]); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to prune objects of kind %s: %w\", gk, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/channels/pkg/channels/prune.go#L41-L77","documentation":"After apiVersion checks, Prune requires each object to have a non-empty kind so it can build a GroupKind key for the keep-set. A document with no `kind` field produces this plain (non-wrapped) error and aborts pruning.","triggerScenarios":"A manifest document omits `kind` entirely (or sets `kind: \"\"`), e.g. a bare List item, a ConfigMap snippet, or a comment-only YAML document that still loads as an object.","commonSituations":"Hand-written or generated manifests missing kind; copying partial resource snippets from documentation; YAML anchors/lists accidentally producing an empty document.","solutions":["Add the correct `kind` field to the offending document in the addon manifest","Remove empty/placeholder documents from the multi-document manifest","Validate the whole file with `kubectl apply --dry-run=client -f manifest.yaml`"],"exampleFix":"// before\napiVersion: v1\nmetadata:\n  name: cm\n// after\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: cm","handlingStrategy":"validation","validationCode":"func checkKinds(manifest []byte) error {\n    objs, _ := kubemanifest.LoadObjectsFrom(manifest)\n    for _, o := range objs {\n        if o.Kind() == \"\" {\n            return fmt.Errorf(\"document without kind: apiVersion=%q name=%q\", o.APIVersion(), o.GetName())\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := pruner.Prune(ctx, manifest, spec); err != nil && err.Error() == \"failed to find kind in object\" {\n    return fmt.Errorf(\"manifest contains a document missing kind; fix before pruning\")\n}","preventionTips":["Validate each YAML document has apiVersion+kind before committing to the channel","Remove empty or placeholder documents from multi-doc manifests","Use kubeconform/`kubectl create --dry-run=client` in CI to catch missing kinds"],"tags":["kind","manifest","validation","kubernetes"],"backgroundTag":"missing-kind-field","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"}