kubernetes/kops · error

error parsing version %q for package %q

Error message

error parsing version %q for package %q

What it means

GetPackageVersion parses the matched package's version string with util.ParseVersion. If that string is not a valid semantic version, the error is wrapped with the offending version and package name. It indicates malformed version data in the addons channel, not a lookup problem.

Source

Thrown at pkg/apis/kops/channel.go:437

			if !kopsVersion.IsInRange(versionRange) {
				klog.V(2).Infof("kOps version %q does not match range: %s", kopsVersion, pkg.KopsVersion)
				continue
			}
		}

		matches = append(matches, pkg)
	}

	if len(matches) == 0 {
		return nil, fmt.Errorf("found no packages in channel for name=%q", name)
	}

	if len(matches) != 1 {
		return nil, fmt.Errorf("found multiple packages in channel for name=%q", name)
	}
	v, err := util.ParseVersion(matches[0].Version)
	if err != nil {
		return nil, fmt.Errorf("error parsing version %q for package %q", matches[0].Version, name)
	}
	return v, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Inspect the package entry for the named package in your channel YAML and fix the version to a valid semver string (e.g. 1.28.2)
  2. Use the official kOps addons channel instead of a custom/edited one
  3. If it's your own addon, run a semver validator over the channel before publishing

Example fix

# before
- name: networking.example
  version: latest
# after
- name: networking.example
  version: 1.28.0
Defensive patterns

Strategy: validation

Validate before calling

func isValidSemver(v string) bool {
    return regexp.MustCompile(`^v?\d+\.\d+\.\d+([-+].*)?$`).MatchString(v)
}
// validate channel entries before use: if !isValidSemver(pkg.Version) { ... }

Prevention

When it happens

Trigger: GetPackageVersion finds exactly one package match, but its version field is not parseable as a semver (e.g. "latest", "v1.x", empty, or a git ref) — raised via CreateAddons during cluster creation/update.

Common situations: Hand-edited channel files with a placeholder or branch-name version; an addon entry copied from docs missing the version; a channel generated by a script writing non-semver output.

Related errors


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