{"record":{"id":"2a03dccdd820f980","repo":"argoproj/argo-workflows","slug":"failure-to-create-dynamic-client-w","errorCode":null,"errorMessage":"failure to create dynamic client: %w","messagePattern":"failure to create dynamic client: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/apiclient/argo-kube-client.go","lineNumber":91,"sourceCode":"\tcwfTmplStore      types.ClusterWorkflowTemplateStore\n\twfLister          store.WorkflowLister\n\twfStore           store.WorkflowStore\n\tnamespace         string\n\tkubeClient        *kubernetes.Clientset\n}\n\nvar _ Client = &argoKubeClient{}\n\nfunc newArgoKubeClient(ctx context.Context, opts ArgoKubeOpts, clientConfig clientcmd.ClientConfig, instanceIDService instanceid.Service) (context.Context, Client, error) {\n\trestConfig, err := clientConfig.ClientConfig()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tversion := argo.GetVersion()\n\trestConfig = restclient.AddUserAgent(restConfig, fmt.Sprintf(\"argo-workflows/%s argo-api-client\", version.Version))\n\tdynamicClient, err := dynamic.NewForConfig(restConfig)\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failure to create dynamic client: %w\", err)\n\t}\n\twfClient, err := workflow.NewForConfig(restConfig)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tnamespace, _, err := clientConfig.Namespace()\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\teventInterface, err := events.NewForConfig(restConfig)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tkubeClient, err := kubernetes.NewForConfig(restConfig)\n\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\tclients := &types.Clients{","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/pkg/apiclient/argo-kube-client.go#L73-L109","documentation":"newArgoKubeClient builds a dynamic Kubernetes client from the caller's rest.Config. If dynamic.NewForConfig fails (bad host, malformed URL, invalid TLS settings, unusable transport config), the error is wrapped as \"failure to create dynamic client\". This happens before any network call, so it indicates a bad rest.Config, not connectivity.","triggerScenarios":"NewClientFromOptsWithContext with direct-kube transport where clientConfig.ClientConfig yields a malformed rest.Config — wrong ARGO_SERVER host format, invalid certificate/CA data in KUBECONFIG, or a clientConfig whose Namespace()/host fields are unset.","commonSituations":"KUBECONFIG pointing to a cluster with a broken/mis-encoded CA or client cert; ARGO_SERVER env var set to something unparseable; running outside a cluster without a valid kubeconfig (missing ~.kube/config).","solutions":["Inspect the wrapped error (%w) for the underlying rest.Config problem and fix the kubeconfig/host/TLS settings","Test that kubectl works with the same KUBECONFIG","If not using direct-kube, set ArgoServerOpts.URL so the kube client is never constructed"],"exampleFix":"// before (bad kubeconfig)\nserver: \"https://my-cluster\"  # missing port/scheme details, bad CA\n// after\nexport KUBECONFIG=/path/to/valid/config && kubectl cluster-info  # verify first, then rerun argo","handlingStrategy":"try-catch","validationCode":"restCfg, err := clientConfig.ClientConfig()\nif err != nil { return err }\nif restCfg.Host == \"\" { return errors.New(\"empty API host in rest.Config\") }\n// sanity probe\nprobe, err := kubernetes.NewForConfig(restCfg)\nif err != nil { return fmt.Errorf(\"rest.Config invalid: %w\", err) }\n_, err = probe.Discovery().ServerVersion()","typeGuard":null,"tryCatchPattern":"client, err := apiclient.NewAPIClient(ctx, opts)\nif err != nil {\n    if strings.Contains(err.Error(), \"failure to create dynamic client\") {\n        return fmt.Errorf(\"check KUBECONFIG/rest.Config validity: %w\", err)\n    }\n    return err\n}","preventionTips":["Verify kubectl works with the same kubeconfig before running argo tooling","Regenerate service account tokens/CA bundles that may have expired","Never hand-edit certificate data in kubeconfigs; use kubectl config set-credentials"],"tags":["kubernetes","client","configuration","tls"],"backgroundTag":"kubernetes-client-init-failed","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}