kubernetes/kops · error
failed to find kind in object
Error message
failed to find kind in object
What it means
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.
Source
Thrown at channels/pkg/channels/prune.go:59
if spec == nil {
return nil
}
objects, err := kubemanifest.LoadObjectsFrom(manifest)
if err != nil {
return fmt.Errorf("failed to parse objects: %w", err)
}
objectsByKind := make(map[schema.GroupKind][]*kubemanifest.Object)
for _, object := range objects {
gv, err := schema.ParseGroupVersion(object.APIVersion())
if err != nil || gv.Version == "" {
return fmt.Errorf("failed to parse apiVersion %q", object.APIVersion())
}
kind := object.Kind()
if kind == "" {
return fmt.Errorf("failed to find kind in object")
}
gvk := gv.WithKind(kind)
gk := gvk.GroupKind()
objectsByKind[gk] = append(objectsByKind[gk], object)
}
for i := range spec.Kinds {
pruneKind := &spec.Kinds[i]
gk := schema.GroupKind{Group: pruneKind.Group, Kind: pruneKind.Kind}
if err := p.pruneObjectsOfKind(ctx, gk, pruneKind, objectsByKind[gk]); err != nil {
return fmt.Errorf("failed to prune objects of kind %s: %w", gk, err)
}
}
return nil
}
View on GitHub (pinned to 4c8573c808)
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`
Example fix
// before apiVersion: v1 metadata: name: cm // after apiVersion: v1 kind: ConfigMap metadata: name: cm
Defensive patterns
Strategy: validation
Validate before calling
func checkKinds(manifest []byte) error {
objs, _ := kubemanifest.LoadObjectsFrom(manifest)
for _, o := range objs {
if o.Kind() == "" {
return fmt.Errorf("document without kind: apiVersion=%q name=%q", o.APIVersion(), o.GetName())
}
}
return nil
} Try / catch
if err := pruner.Prune(ctx, manifest, spec); err != nil && err.Error() == "failed to find kind in object" {
return fmt.Errorf("manifest contains a document missing kind; fix before pruning")
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Hand-written or generated manifests missing kind; copying partial resource snippets from documentation; YAML anchors/lists accidentally producing an empty document.
Related errors
- failed to parse apiVersion %q
- failed to parse objects: %w
- failed to parse objects: %w
- invalid InstanceGroup name: %v
- must specify %q label with cluster name to replace SSHCreden
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/33fdbd585fdac571.
Report an issue: GitHub.