{"record":{"id":"2b072f5cc14554f4","repo":"kubernetes/kops","slug":"unable-to-parse-kubernetesversion-q-w","errorCode":null,"errorMessage":"unable to parse KubernetesVersion %q: %w","messagePattern":"unable to parse KubernetesVersion %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"nodeup/pkg/model/context.go","lineNumber":94,"sourceCode":"\n\t// Deprecated: This should be renamed to controlPlaneVersion / nodeVersion;\n\t// controlPlaneVersion should probably/ideally only be populated on control plane nodes.\n\tkubernetesVersion *kopsmodel.KubernetesVersion\n\n\tbootstrapCerts      map[string]*nodetasks.BootstrapCert\n\tbootstrapKeypairIDs map[string]string\n\n\t// ConfigurationMode determines if we are prewarming an instance or running it live\n\tConfigurationMode string\n\tInstanceID        string\n\tMachineType       string\n}\n\n// Init completes initialization of the object, for example pre-parsing the kubernetes version\nfunc (c *NodeupModelContext) Init() error {\n\tk8sVersion, err := kopsmodel.ParseKubernetesVersion(c.NodeupConfig.KubernetesVersion)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to parse KubernetesVersion %q: %w\", c.NodeupConfig.KubernetesVersion, err)\n\t}\n\tc.kubernetesVersion = k8sVersion\n\tc.bootstrapCerts = map[string]*nodetasks.BootstrapCert{}\n\tc.bootstrapKeypairIDs = map[string]string{}\n\n\trole := c.BootConfig.InstanceGroupRole\n\n\tif role.HasControlPlane() {\n\t\tc.IsMaster = true\n\t}\n\n\tif role.HasControlPlane() || role.HasAPIServer() {\n\t\tc.HasAPIServer = true\n\t}\n\n\tc.usesNoneDNS = c.NodeupConfig.UsesNoneDNS\n\tc.discoveryService = c.NodeupConfig.DiscoveryService\n","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/context.go#L76-L112","documentation":"NodeupModelContext.Init (nodeup/pkg/model/context.go:94) pre-parses the Kubernetes version from NodeupConfig.KubernetesVersion using kopsmodel.ParseKubernetesVersion. This error wraps that parse failure and aborts nodeup startup before any model builders run. It indicates the KubernetesVersion string handed to nodeup is empty or not a parseable semver (e.g. missing 'v', extra text, or garbage from a corrupted boot config).","triggerScenarios":"nodeup Run (or runKubeletBuilder in tests) calls Init() while c.NodeupConfig.KubernetesVersion is empty, malformed (e.g. '1.3x.0', 'v1.31.0-beta-extra'), or missing entirely from the nodeup config rendered by kops-controller / protokube.","commonSituations":"Running a mismatched or stale nodeup binary against a newer/older cluster config; hand-crafted nodeup configs for testing omitting KubernetesVersion; corrupted protokobe/nodeup config on the node; custom AMI or bootstrap flows passing the wrong version string.","solutions":["Check the %q value in the error to see exactly what string failed to parse","Verify the cluster spec's kubernetesVersion is a valid semver (e.g. v1.31.0) and re-run kops update/replace to regenerate nodeup config","Ensure the nodeup binary version matches the kops version that rendered the config (avoid version skew)","Re-bootstrap the node or re-render the nodeup config (kops-toolbox nodeup / instance boot) so KubernetesVersion is populated"],"exampleFix":"// before (nodeup config)\n\"kubernetesVersion\": \"1.31\"\n// after\n\"kubernetesVersion\": \"v1.31.0\"","handlingStrategy":"validation","validationCode":"// Before booting nodeup, verify the rendered config's version string:\nif _, err := kopsmodel.ParseKubernetesVersion(cfg.KubernetesVersion); err != nil {\n    return fmt.Errorf(\"nodeup config has invalid KubernetesVersion %q: %w\", cfg.KubernetesVersion, err)\n}","typeGuard":null,"tryCatchPattern":"if err := modelContext.Init(); err != nil {\n    // log full wrapped chain; fail fast, do not retry — config must be fixed\n    klog.Fatalf(\"initializing nodeup model context: %v\", err)\n}","preventionTips":["Always run the nodeup binary built from the same kops version that rendered the config","Never hand-edit KubernetesVersion in rendered nodeup configs","Pin kubernetesVersion in the cluster spec to a full semver with the v prefix","Validate cluster spec changes with kops update --dry-run before applying"],"tags":["nodeup","kubernetes-version","parsing","configuration"],"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-12T07:17:12.445Z"}