kubernetes/kops · error

error parsing addons: %v

Error message

error parsing addons: %v

What it means

ParseAddons, when the first document is a native Addons kind, re-parses it strictly into api.Addons via objects[0].Reparse and wraps failure. The YAML parsed as generic objects but does not conform to the Addons schema (missing/invalid fields, wrong types, rejected unknown fields).

Source

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

	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 {
			return nil, fmt.Errorf("error hashing manifest location: %v", err)
		}
		addonName := "manifest-" + manifestLocationHash[:12]
		addonSpec := &api.AddonSpec{
			Name:         &addonName,
			Manifest:     &manifest,
			ManifestHash: manifestHash,
		}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Compare the addons file against the upstream kops addons channel schema and fix field names/types.
  2. Quote version strings (version: "1.0") so they parse as strings.
  3. Validate with a Go test calling ParseAddons on the file (TestParseAddons-style fixture).
  4. Regenerate the channel from a known-good upstream template.

Example fix

# before
spec:
  addons:
  - name: networking
    manifest: s3://bucket/a.yaml
    version: 1.2   # number
# after
spec:
  addons:
  - name: networking
    manifest: s3://bucket/a.yaml
    version: "1.2"
Defensive patterns

Strategy: validation

Validate before calling

// check first doc is a well-formed Addons object before Reparse
var probe struct {
	Kind string                 `yaml:"kind"`
	Spec map[string]interface{} `yaml:"spec"`
}
if err := yaml.Unmarshal(data, &probe); err != nil {
	return err
}
if probe.Kind == "Addons" && probe.Spec == nil {
	return errors.New("Addons document missing spec")
}

Try / catch

addons, err := channels.ParseAddons(name, location, data)
if err != nil {
	if strings.Contains(err.Error(), "error parsing addons") {
		return fmt.Errorf("addons channel schema invalid at %s: %w", location, err)
	}
	return err
}

Prevention

When it happens

Trigger: LoadAddons -> ParseAddons where objects[0] has GVK kind Addons (group/version empty) and Reparse into api.Addons fails: addon entries missing required name/manifest fields, type mismatches (e.g. unquoted numeric version), unknown fields.

Common situations: Custom addons channel with schema typos ('spe:' instead of 'spec:', addon items missing 'manifest'); channel written for an older kops version using removed fields; unquoted version numbers.

Related errors


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