{"record":{"id":"3446c4664cb8b656","repo":"kubernetes/kops","slug":"cannot-parse-kubernetesversion-q-in-cluster-w","errorCode":null,"errorMessage":"cannot parse KubernetesVersion %q in cluster: %w","messagePattern":"cannot parse KubernetesVersion %q in cluster: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_cluster.go","lineNumber":746,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"error populating configuration: %v\", err)\n\t}\n\n\tstrict := false\n\terr = validation.DeepValidate(cluster, instanceGroups, strict, clientset.VFSContext(), nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tassetBuilder := assets.NewAssetBuilder(clientset.VFSContext(), cluster.Spec.Assets, false)\n\tfullCluster, err := cloudup.PopulateClusterSpec(ctx, clientset, cluster, instanceGroups, cloud, assetBuilder)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tkubernetesVersion, err := kopsutil.ParseKubernetesVersion(clusterResult.Cluster.Spec.KubernetesVersion)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot parse KubernetesVersion %q in cluster: %w\", clusterResult.Cluster.Spec.KubernetesVersion, err)\n\t}\n\n\taddons, err := wellknownoperators.CreateAddons(clusterResult.Channel, kubernetesVersion, fullCluster)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tfor _, p := range c.AddonPaths {\n\t\taddon, err := clusteraddons.LoadClusterAddon(clientset.VFSContext(), p)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error loading cluster addon %s: %v\", p, err)\n\t\t}\n\t\taddons = append(addons, addon.Objects...)\n\t}\n\n\t{\n\t\t// Build full IG spec to ensure we end up with a valid IG\n\t\tfullInstanceGroups := []*api.InstanceGroup{}","sourceCodeStart":728,"sourceCodeEnd":764,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_cluster.go#L728-L764","documentation":"RunCreateCluster parses cluster.Spec.KubernetesVersion with kopsutil.ParseKubernetesVersion to decide which well-known addons apply; an unparseable version fails with 'cannot parse KubernetesVersion %q in cluster'. This guards against channel/spec versions that don't match expected semver-like formats.","triggerScenarios":"Creating a cluster whose spec has a KubernetesVersion that isn't a valid version string — e.g. a placeholder, a channel alias, an empty string, or a typo like '1.2x.3'.","commonSituations":"Manually editing the cluster spec with a bad version; using an alpha/dev version string format not accepted; copying a spec from another cluster with a custom version; newest kops rejecting a legacy version format.","solutions":["Set KubernetesVersion to a valid plain version like 1.28.4 (no v prefix needed, no aliases)","Run `kops replace -f` / `kops edit cluster` with the corrected version, then rerun create/update","Check for typos (e.g. stray characters, whitespace) in the cluster manifest","Upgrade kops if the version format is newer than the tool understands"],"exampleFix":"// before (cluster.yaml)\nkubernetesVersion: \"v1.28 latest\"\n// after\nkubernetesVersion: \"1.28.4\"","handlingStrategy":"validation","validationCode":"func validK8sVersion(v string) error {\n\tif v == \"\" { return fmt.Errorf(\"kubernetesVersion empty\") }\n\tv = strings.TrimPrefix(v, \"v\")\n\tparts := strings.Split(v, \".\")\n\tif len(parts) < 2 { return fmt.Errorf(\"want major.minor[.patch]: %q\", v) }\n\tfor _, p := range parts {\n\t\tif _, err := strconv.Atoi(p); err != nil {\n\t\t\treturn fmt.Errorf(\"bad version %q: %w\", v, err)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use plain semver strings (1.28.4) in cluster specs","Avoid free-text versions or channel aliases in KubernetesVersion","Validate manifests with a schema check before kops replace","Keep kops current so new version formats parse"],"tags":["kubernetes-version","parsing","validation"],"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-12T07:17:12.445Z"}