kubernetes/kops · error

error parsing addons or manifest: %v

Error message

error parsing addons or manifest: %v

What it means

ParseAddons wraps failures from kubemanifest.LoadObjectsFrom while converting the addons file into Kubernetes objects. The raw bytes were fetched fine but are not valid YAML/Kubernetes manifests (or a multi-doc stream cannot be decoded).

Source

Thrown at channels/pkg/channels/addons.go:53

	APIObject       *api.Addons
}

func LoadAddons(vfsContext *vfs.VFSContext, name string, location *url.URL) (*Addons, error) {
	klog.V(2).Infof("Loading addons channel from %q", location)
	data, err := vfsContext.ReadFile(location.String())
	if err != nil {
		return nil, fmt.Errorf("error reading addons from %q: %v", location, err)
	}

	return ParseAddons(name, location, data)
}

func ParseAddons(name string, location *url.URL, data []byte) (*Addons, error) {
	configString := strings.TrimSpace(string(data))

	objects, err := kubemanifest.LoadObjectsFrom([]byte(configString))
	if err != nil {
		return nil, fmt.Errorf("error parsing addons or manifest: %v", err)
	}

	apiObject := &api.Addons{}
	if len(objects) == 0 {
		// No objects (empty, whitespace, or comment-only content): nothing to apply.
	} else if gvk := objects[0].GroupVersionKind(); gvk.Kind == "Addons" && gvk.Group == "" && gvk.Version == "" {
		// Reuse the document already parsed by LoadObjectsFrom instead of parsing it again.
		if err := objects[0].Reparse(apiObject); err != nil {
			return nil, fmt.Errorf("error parsing addons: %v", err)
		}
	} else {
		manifest := location.String()
		manifestHash, err := utils.HashString(configString)
		if err != nil {
			return nil, fmt.Errorf("error hashing manifest: %v", err)
		}
		manifestLocationHash, err := utils.HashString(manifest)
		if err != nil {

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Run the file through a YAML linter / kubectl apply --dry-run=client to find the syntax error at the reported line.
  2. Fix indentation (spaces not tabs) and document separators ('---').
  3. Restore the original addons channel from upstream if it was hand-modified.
  4. Confirm the URL actually serves raw YAML, not a storage/XML error page.

Example fix

# before (addons.yaml)
kind: Addons
metadata:
	name: my-addon   # tab indentation
# after
kind: Addons
metadata:
  name: my-addon   # spaces only
Defensive patterns

Strategy: validation

Validate before calling

// validate before calling ParseAddons
if err := yaml.Unmarshal(data, &map[string]interface{}{}); err != nil {
	return fmt.Errorf("addons file is not valid YAML: %w", err)
}
if bytes.Contains(data, []byte("\t")) {
	return errors.New("addons file contains tab indentation")
}

Try / catch

addons, err := channels.ParseAddons(name, location, data)
if err != nil {
	if strings.Contains(err.Error(), "error parsing addons or manifest") {
		// surface the file for a YAML lint
		os.WriteFile("/tmp/bad-addons.yaml", data, 0o644)
	}
	return err
}

Prevention

When it happens

Trigger: LoadAddons -> ParseAddons with data that fails LoadObjectsFrom: invalid YAML syntax, tabs in YAML, wrong document structure, binary/HTML content, or a multi-document stream with malformed separators.

Common situations: Hand-edited addons channel with YAML indentation mistakes; CI tooling uploaded an HTML error page instead of YAML; Windows line endings/tabs; concatenated manifests missing '---' separators.

Related errors


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