{"record":{"id":"e6c4762a95759e85","repo":"kubernetes/kops","slug":"error-parsing-kubernetes-version-q-v","errorCode":null,"errorMessage":"error parsing Kubernetes version %q: %v","messagePattern":"error parsing Kubernetes version %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apis/kops/model/instance_group.go","lineNumber":84,"sourceCode":"\treturn m.kubernetesVersion\n}\n\nfunc (m *instanceGroupModel) GetCloudProvider() kops.CloudProviderID {\n\treturn m.cluster.GetCloudProvider()\n}\n\nfunc (m *instanceGroupModel) InstallCNIAssets() bool {\n\treturn m.cluster.InstallCNIAssets()\n}\n\nfunc (m *instanceGroupModel) RawClusterSpec() *kops.ClusterSpec {\n\treturn &m.cluster.Spec\n}\n\nfunc (m *instanceGroupModel) ForceKubernetesVersion(kubernetesVersionString string) error {\n\tkubernetesVersion, err := ParseKubernetesVersion(kubernetesVersionString)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing Kubernetes version %q: %v\", kubernetesVersionString, err)\n\t}\n\tm.kubernetesVersion = kubernetesVersion\n\treturn nil\n}\n","sourceCodeStart":66,"sourceCodeEnd":89,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/apis/kops/model/instance_group.go#L66-L89","documentation":"ForceKubernetesVersion on the instance group model parses the given Kubernetes version string via ParseKubernetesVersion and stores it on the model. If parsing fails, the error is wrapped with the input string and the underlying reason. It surfaces malformed version inputs reaching the model layer (e.g. from cluster spec or tests).","triggerScenarios":"Calling ForceKubernetesVersion (from ForInstanceGroup during model building) with a string that util.ParseKubernetesVersion rejects — e.g. empty string, \"1.28\", \"v1.28.0-beta\" with unexpected format, or arbitrary text from a misconfigured kubernetesVersion field.","commonSituations":"Cluster spec has kubernetesVersion set to a non-standard value; user pinned a version like \"stable\" or omitted the patch number; a template/variable substitution produced an empty version string.","solutions":["Set the cluster's spec.kubernetesVersion to a full, valid version string (e.g. 1.28.2, with or without a leading v)","Check for empty or placeholder values leaking from templating/config into kubernetesVersion","Pin to a kOps-supported Kubernetes release version"],"exampleFix":"# before (cluster.yaml)\nspec:\n  kubernetesVersion: stable\n# after\nspec:\n  kubernetesVersion: 1.28.2","handlingStrategy":"try-catch","validationCode":"if kubernetesVersion == \"\" || !regexp.MustCompile(`^v?\\d+\\.\\d+\\.\\d+`).MatchString(kubernetesVersion) {\n    return errors.New(\"kubernetesVersion must be a full version like 1.28.2\")\n}","typeGuard":null,"tryCatchPattern":"kubernetesVersion, err := m.ForceKubernetesVersion(versionString)\nif err != nil {\n    return fmt.Errorf(\"refusing to build model: %w\", err)\n}","preventionTips":["Pin full semver kubernetesVersion in cluster specs","Guard templating so empty values cannot reach the version field","Check kops support matrix for the pinned version"],"tags":["kops","version-parsing","kubernetes-version","instance-group"],"backgroundTag":"invalid-kubernetes-version","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"}