{"record":{"id":"ba6f3061fa6b2767","repo":"kubernetes/kops","slug":"error-parsing-version-q-for-package-q","errorCode":null,"errorMessage":"error parsing version %q for package %q","messagePattern":"error parsing version %q for package %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/kops/channel.go","lineNumber":437,"sourceCode":"\t\t\tif !kopsVersion.IsInRange(versionRange) {\n\t\t\t\tklog.V(2).Infof(\"kOps version %q does not match range: %s\", kopsVersion, pkg.KopsVersion)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tmatches = append(matches, pkg)\n\t}\n\n\tif len(matches) == 0 {\n\t\treturn nil, fmt.Errorf(\"found no packages in channel for name=%q\", name)\n\t}\n\n\tif len(matches) != 1 {\n\t\treturn nil, fmt.Errorf(\"found multiple packages in channel for name=%q\", name)\n\t}\n\tv, err := util.ParseVersion(matches[0].Version)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing version %q for package %q\", matches[0].Version, name)\n\t}\n\treturn v, nil\n}\n","sourceCodeStart":419,"sourceCodeEnd":441,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/apis/kops/channel.go#L419-L441","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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)","Use the official kOps addons channel instead of a custom/edited one","If it's your own addon, run a semver validator over the channel before publishing"],"exampleFix":"# before\n- name: networking.example\n  version: latest\n# after\n- name: networking.example\n  version: 1.28.0","handlingStrategy":"validation","validationCode":"func isValidSemver(v string) bool {\n    return regexp.MustCompile(`^v?\\d+\\.\\d+\\.\\d+([-+].*)?$`).MatchString(v)\n}\n// validate channel entries before use: if !isValidSemver(pkg.Version) { ... }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use full semver strings in channel entries","Never use placeholders like latest in version fields","Lint channel YAML before publishing"],"tags":["kops","channel","version-parsing","semver"],"backgroundTag":"invalid-version-string","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}