kubernetes/kops · error
failed to parse apiVersion %q
Error message
failed to parse apiVersion %q
What it means
Wraps schema.ParseGroupVersion failure while parsing a manifest object's apiVersion during prune-directive construction. Fires when the addon manifest being normalized contains an apiVersion that is not a valid 'group/version' string (e.g. missing version).
Source
Thrown at upup/pkg/fi/cloudup/bootstrapchannelbuilder/pruning.go:93
//
// * Namespace: because it deletes anything else that happens to be in the namespace
//
// * CustomResourceDefinition: because it deletes all instances of the CRD
neverPruneGroupKinds := map[schema.GroupKind]bool{
{Group: "", Kind: "Namespace"}: true,
{Group: "apiextensions.k8s.io", Kind: "CustomResourceDefinition"}: true,
}
// Parse the manifest; we use this to scope pruning to namespaces
objects, err := kubemanifest.LoadObjectsFrom(manifestData)
if err != nil {
return fmt.Errorf("failed to parse manifest: %w", err)
}
objectsByGK := 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())
}
gvk := gv.WithKind(object.Kind())
if gvk.Kind == "" {
return fmt.Errorf("failed to get kind for object")
}
gk := gvk.GroupKind()
objectsByGK[gk] = append(objectsByGK[gk], object)
// Warn if there are objects in the manifest that we haven't considered
if !pruneGroupKind[gk] {
if !neverPruneGroupKinds[gk] {
klog.Warningf("manifest includes an object of GroupKind %v, which will not be pruned", gk)
}
}
}
var groupKinds []schema.GroupKindView on GitHub (pinned to 4c8573c808)
Solutions
- Fix the apiVersion field in the affected addon manifest
- Check for typos such as missing /version segment
- Regenerate/re-render the addon after correcting the manifest
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at upup/pkg/fi/cloudup/bootstrapchannelbuilder/pruning.go:93 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/571b26a229b5e320.
Report an issue: GitHub.