kubernetes/kops · error

failed to parse manifest: %w

Error message

failed to parse manifest: %w

What it means

buildPruneDirectives parses the addon's manifest data with kubemanifest.LoadObjectsFrom to determine namespaces for scoped pruning. If the YAML is not parseable as Kubernetes objects, this error wraps the parse failure.

Source

Thrown at upup/pkg/fi/cloudup/bootstrapchannelbuilder/pruning.go:87

	pruneGroupKind := make(map[schema.GroupKind]bool)
	for _, gk := range alwaysPruneGroupKinds {
		pruneGroupKind[gk] = true
	}

	// In addition, we deliberately exclude a few types that are riskier to delete:
	//
	//  * 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] {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run the manifest through a YAML/kubectl linter (kubectl apply --dry-run=client) to find the parse error
  2. Fix the YAML syntax at the location reported by the wrapped error
  3. Ensure every document has apiVersion and kind
  4. Re-download the addon manifest from its official channel

Example fix

// before: document missing kind
apiVersion: v1
metadata:
  name: broken
// after
apiVersion: v1
kind: ConfigMap
metadata:
  name: ok
Defensive patterns

Strategy: validation

Validate before calling

// Pre-parse the manifest to catch YAML errors before kops does
if _, err := kubemanifest.LoadObjectsFrom(manifestData); err != nil {
    return fmt.Errorf("addon manifest invalid: %w", err)
}

Try / catch

objects, err := kubemanifest.LoadObjectsFrom(manifestData)
if err != nil {
    klog.Errorf("fix YAML at reported offset in addon manifest: %v", err)
    return err
}

Prevention

When it happens

Trigger: Normalizing an AddonManifest whose rendered manifest bytes contain invalid YAML, non-object documents, or content that LoadObjectsFrom cannot decode into Kubernetes objects.

Common situations: Hand-edited addon manifests with syntax errors; manifests containing plain documents without apiVersion/kind; binary or truncated manifest contents; template placeholders left unrendered.

Understand the failure class

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/f302ff1ba0627ca2. Report an issue: GitHub.