{"record":{"id":"8d9d11c11e2720c9","repo":"kubernetes/kops","slug":"building-dynamic-client-w","errorCode":null,"errorMessage":"building dynamic client: %w","messagePattern":"building dynamic client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/pkg/cmd/apply_channel.go","lineNumber":180,"sourceCode":"\t}\n\thttpClient, err := f.HTTPClient()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tk8sClient, err := f.KubernetesClient()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"building kube client: %w\", err)\n\t}\n\n\tcmClient, err := certmanager.NewForConfigAndClient(restConfig, httpClient)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"building cert manager client: %w\", err)\n\t}\n\n\tdynamicClient, err := f.DynamicClient()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"building dynamic client: %w\", err)\n\t}\n\n\trestMapper, err := f.RESTMapper()\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tkubernetesVersionInfo, err := k8sClient.Discovery().ServerVersion()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error querying kubernetes version: %v\", err)\n\t}\n\n\tkubernetesVersion, err := semver.ParseTolerant(kubernetesVersionInfo.GitVersion)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot parse kubernetes version %q\", kubernetesVersionInfo.GitVersion)\n\t}\n\n\t// Remove Pre and Patch, as they make semver comparisons impractical","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/channels/pkg/cmd/apply_channel.go#L162-L198","documentation":"RunApplyChannel wraps failures from f.DynamicClient() with this message. The dynamic (unstructured) client is needed to manage arbitrary addon resources; its construction fails for the same class of reasons as the typed client — bad REST config or transport.","triggerScenarios":"`kops channels apply` where the factory's RESTConfig is invalid or its transport cannot be built for the dynamic client: missing host, bad TLS material, unsupported config.","commonSituations":"Same misconfigurations as other client-build errors, usually surfacing here first if only the dynamic client path exercises the bad field; broken kubeconfig after cluster rebuild.","solutions":["Validate the kubeconfig with `kubectl --kubeconfig <path> get ns`","Regenerate the kubeconfig via kops export kubeconfig","Ensure CA cert and client cert/key paths exist and are readable in the execution environment","Check the wrapped inner error for the failing config field"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: preflight REST config before building the dynamic client\nrestConfig, err := f.RESTConfig()\nif err != nil || restConfig.Host == \"\" {\n\treturn fmt.Errorf(\"precheck: REST config invalid: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"err := RunApplyChannel(ctx, f, out, options, args)\nif err != nil && strings.Contains(err.Error(), \"building dynamic client\") {\n\tklog.Errorf(\"dynamic client init failed: %v\", err)\n\t// fix kubeconfig/TLS, then retry\n}","preventionTips":["Validate kubeconfig with kubectl before running kops channels","Mount required CA/token files in the executing pod","Regenerate kubeconfig after cluster replacement","Check wrapped inner error to identify the bad config field"],"tags":["kubernetes","dynamic-client","client-init","kubeconfig"],"backgroundTag":"kube-client-init-failed","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"}