{"record":{"id":"3e960216a07d63cb","repo":"kubernetes/kops","slug":"building-dynamic-client-w-3e9602","errorCode":null,"errorMessage":"building dynamic client: %w","messagePattern":"building dynamic client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/util/factory.go","lineNumber":242,"sourceCode":"func (f *Factory) DynamicClient(ctx context.Context, cluster *kops.Cluster, options kubeconfig.CreateKubecfgOptions) (dynamic.Interface, error) {\n\tclusterInfo := f.getClusterInfo(cluster, options)\n\trestConfig, err := clusterInfo.RESTConfig(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn clusterInfo.DynamicClient(restConfig)\n}\n\nfunc (f *clusterInfo) DynamicClient(restConfig *rest.Config) (dynamic.Interface, error) {\n\tif f.cachedDynamicClient == nil {\n\t\thttpClient, err := f.HTTPClient(restConfig)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tdynamicClient, err := dynamic.NewForConfigAndClient(restConfig, httpClient)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"building dynamic client: %w\", err)\n\t\t}\n\t\tf.cachedDynamicClient = dynamicClient\n\t}\n\treturn f.cachedDynamicClient, nil\n}\n\nfunc (f *Factory) VFSContext() *vfs.VFSContext {\n\tif f.vfsContext == nil {\n\t\t// TODO vfs.NewVFSContext()\n\t\tf.vfsContext = vfs.Context\n\t}\n\treturn f.vfsContext\n}\n\nfunc (f *Factory) buildRESTConfig(ctx context.Context, cluster *kops.Cluster, options kubeconfig.CreateKubecfgOptions) (*rest.Config, error) {\n\tclientset, err := f.KopsClient()\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/util/factory.go#L224-L260","documentation":"Wraps a failure of dynamic.NewForConfigAndClient in clusterInfo.DynamicClient: the Kubernetes dynamic client could not be constructed from the REST config and HTTP client, usually due to invalid server URL or auth material in kubeconfig.","triggerScenarios":"Thrown at cmd/kops/util/factory.go:242 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the API server URL in kubeconfig","Refresh client certificates","Ensure the exec credential plugin works"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}