kubernetes/kops · error

error parsing addon %q: %v

Error message

error parsing addon %q: %v

What it means

Once the addon bytes are read, LoadClusterAddon passes them to ParseClusterAddon; a parse failure is re-wrapped with the resolved location. It indicates the fetched file is not a valid set of Kubernetes manifests / addon definition.

Source

Thrown at pkg/clusteraddons/load.go:50

// LoadClusterAddon loads a set of objects from the specified VFS location
func LoadClusterAddon(vfsContext *vfs.VFSContext, location string) (*ClusterAddon, error) {
	u, err := url.Parse(location)
	if err != nil {
		return nil, fmt.Errorf("invalid addon location: %q", location)
	}

	// TODO: Should we support relative paths for "standard" addons?  See equivalent code in LoadChannel

	resolved := u.String()
	klog.V(2).Infof("Loading addon from %q", resolved)
	addonBytes, err := vfsContext.ReadFile(resolved)
	if err != nil {
		return nil, fmt.Errorf("error reading addon %q: %v", resolved, err)
	}
	addon, err := ParseClusterAddon(addonBytes)
	if err != nil {
		return nil, fmt.Errorf("error parsing addon %q: %v", resolved, err)
	}
	klog.V(4).Infof("Addon contents: %s", string(addonBytes))

	return addon, nil
}

// ParseClusterAddon parses a ClusterAddon object
func ParseClusterAddon(raw []byte) (*ClusterAddon, error) {
	objects, err := kubemanifest.LoadObjectsFrom(raw)
	if err != nil {
		return nil, fmt.Errorf("error parsing addon %v", err)
	}

	return &ClusterAddon{Raw: string(raw), Objects: objects}, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the content at the resolved location and confirm it is valid YAML manifests.
  2. Point the addon location to the correct raw manifest file, not an HTML page or index.
  3. Re-upload/re-download the addon file if it was truncated or corrupted.

Example fix

// before
addon, err := LoadClusterAddon(vfs.Context, "https://example.com/addons/") // HTML index
// after
addon, err := LoadClusterAddon(vfs.Context, "https://example.com/addons/rbac-addon.yaml")
Defensive patterns

Strategy: validation

Validate before calling

// confirm the location serves YAML, not an HTML page
body, err := fetchPreview(resolved)
if err == nil && (strings.HasPrefix(strings.TrimSpace(string(body)), "<") || len(body) == 0) {
  return fmt.Errorf("location %q does not serve a manifest", resolved)
}

Try / catch

addon, err := LoadClusterAddon(vfs.Context, loc)
if err != nil && strings.Contains(err.Error(), "error parsing addon") {
  return fmt.Errorf("location %s does not contain a valid addon manifest; check it points to the raw YAML file", loc)
}

Prevention

When it happens

Trigger: LoadClusterAddon fetches content that ParseClusterAddon cannot decode: an HTML error page instead of YAML, truncated download, wrong file, or YAML that fails Kubernetes object decoding.

Common situations: S3/proxy returning an error page with HTTP 200; addon URL pointing to an HTML index rather than the manifest; partially uploaded/corrupted addon file in the state store.

Related errors


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