{"record":{"id":"fe8f3b44e1482a42","repo":"kubernetes/kops","slug":"unexpected-error-creating-validatior-v","errorCode":null,"errorMessage":"unexpected error creating validatior: %v","messagePattern":"unexpected error creating validatior: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/validate_cluster.go","lineNumber":184,"sourceCode":"\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting rest config: %w\", err)\n\t}\n\n\thttpClient, err := f.HTTPClient(restConfig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"getting http client: %w\", err)\n\t}\n\n\tk8sClient, err := kubernetes.NewForConfigAndClient(restConfig, httpClient)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building kubernetes client: %w\", err)\n\t}\n\n\ttimeout := time.Now().Add(options.wait)\n\n\tvalidator, err := validation.NewClusterValidator(cluster, cloud, list, options.filterInstanceGroups, options.filterPodsForValidation, options.MaxUnreadyNodes, restConfig, k8sClient)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unexpected error creating validatior: %v\", err)\n\t}\n\n\tconsecutive := 0\n\tfor {\n\t\tif options.wait > 0 && time.Now().After(timeout) && consecutive == 0 {\n\t\t\treturn nil, fmt.Errorf(\"wait time exceeded during validation\")\n\t\t}\n\n\t\tresult, err := validator.Validate(ctx)\n\t\tif err != nil {\n\t\t\tconsecutive = 0\n\t\t\tif options.wait > 0 {\n\t\t\t\tklog.Warningf(\"(will retry): unexpected error during validation: %v\", err)\n\t\t\t\ttime.Sleep(options.interval)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\treturn nil, fmt.Errorf(\"unexpected error during validation: %v\", err)\n\t\t\t}","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/validate_cluster.go#L166-L202","documentation":"This error is returned when validation.NewClusterValidator fails to assemble the cluster validator, which needs the cluster spec, cloud provider, instance group list, filters, rest config, and k8s client. The message (note the 'validatior' typo) indicates a programming/config-level problem inside the validation package, not a cluster health issue. It uses %v rather than %w, so the cause cannot be unwrapped programmatically.","triggerScenarios":"Calling validation.NewClusterValidator with an incomplete cluster object, nil cloud provider, missing instance groups, or invalid restConfig/k8sClient combination that the validator constructor rejects (e.g. missing discovery client inputs).","commonSituations":"Running `kops validate cluster` against a cluster whose state store entry is partially written; cluster object missing required spec fields after a failed update; cloud API credentials absent so cloud handle is unusable.","solutions":["Re-run `kops export kubecfg <cluster>` and verify `kops get cluster` returns a complete spec before validating.","Check the printed %v cause — validate the cluster spec fields it names (e.g. missing kubeAPI config).","Ensure cloud credentials are present (AWS/GCP/etc. env or profile) since the validator needs the cloud handle.","Retry after a completed `kops update cluster --yes` so state store and cloud resources are consistent.","Upgrade kops — constructor signature/behavior changed across versions; a stale binary against a newer state store can fail here."],"exampleFix":"// before\nvalidator, err := validation.NewClusterValidator(cluster, cloud, list, ...)\nif err != nil {\n\treturn nil, fmt.Errorf(\"unexpected error creating validatior: %v\", err)\n}\n// after\nvalidator, err := validation.NewClusterValidator(cluster, cloud, list, ...)\nif err != nil {\n\treturn nil, fmt.Errorf(\"unexpected error creating validator: %w\", err)\n}","handlingStrategy":"validation","validationCode":"cluster, err := clientset.GetCluster(ctx, clusterName)\nif err != nil { return err }\nif cloud == nil { return errors.New(\"cloud handle unavailable: check cloud credentials\") }\nif len(instanceGroups.Items) == 0 { return errors.New(\"no instance groups found\") }","typeGuard":"func canBuildValidator(cluster *kops.Cluster, cloud cloudproviders.Cloud, igs *kops.InstanceGroupList) bool {\n\treturn cluster != nil && cluster.Spec.KubernetesAPIAccess != nil && cloud != nil && len(igs.Items) > 0\n}","tryCatchPattern":null,"preventionTips":["Complete `kops update cluster --yes` before validating.","Ensure cloud provider credentials are exported (AWS_PROFILE/GCP creds etc.).","Verify `kops get cluster <name>` returns a full spec, not a stub.","Keep kops binary version aligned with the cluster state store version."],"tags":["kubernetes","validation","kops"],"backgroundTag":"validator-creation-failed","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"}