{"record":{"id":"50ace644abb99bba","repo":"GoogleContainerTools/skaffold","slug":"instantiating-default-kubectl-deployer-w","errorCode":null,"errorMessage":"instantiating default kubectl deployer: %w","messagePattern":"instantiating default kubectl deployer: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/runner/deployer.go","lineNumber":297,"sourceCode":"\t\t}\n\t\tif currentDefaultNamespace != nil {\n\t\t\tif defaultNamespace != nil && *defaultNamespace != *currentDefaultNamespace {\n\t\t\t\treturn nil, fmt.Errorf(\"found multiple namespaces in skaffold.yaml (not supported in `skaffold apply`): %s, %s\", *defaultNamespace, *currentDefaultNamespace)\n\t\t\t}\n\t\t\tdefaultNamespace = currentDefaultNamespace\n\t\t}\n\t}\n\tif kFlags == nil {\n\t\tkFlags = &latest.KubectlFlags{}\n\t}\n\tk := &latest.KubectlDeploy{\n\t\tFlags:            *kFlags,\n\t\tDefaultNamespace: defaultNamespace,\n\t}\n\tdCtx := &deployerCtx{runCtx, latest.DeployConfig{StatusCheck: statusCheck, KubeContext: kubeContext, DeployType: latest.DeployType{KubectlDeploy: k}}}\n\tdefaultDeployer, err := kubectl.NewDeployer(dCtx, labeller, k, runCtx.Artifacts(), \"\", selectors)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"instantiating default kubectl deployer: %w\", err)\n\t}\n\treturn defaultDeployer, nil\n}\n\nfunc validateKubectlFlags(flags *latest.KubectlFlags, additional latest.KubectlFlags) error {\n\terrStr := \"conflicting sets of kubectl deploy flags not supported in `skaffold apply` (flag: %s)\"\n\tif additional.DisableValidation != flags.DisableValidation {\n\t\treturn fmt.Errorf(errStr, strconv.FormatBool(additional.DisableValidation))\n\t}\n\tfor _, flag := range additional.Apply {\n\t\tif !stringslice.Contains(flags.Apply, flag) {\n\t\t\treturn fmt.Errorf(errStr, flag)\n\t\t}\n\t}\n\tfor _, flag := range additional.Delete {\n\t\tif !stringslice.Contains(flags.Delete, flag) {\n\t\t\treturn fmt.Errorf(errStr, flag)\n\t\t}","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/runner/deployer.go#L279-L315","documentation":"Wraps any error returned when Skaffold constructs its default kubectl deployer during `skaffold apply`/`deploy` fallback. kubectl.NewDeployer fails if the kubectl deploy config or its flags are invalid (e.g. bad kube-context values, invalid flags). The inner error identifies the concrete problem.","triggerScenarios":"getDefaultDeployer calls kubectl.NewDeployer with the parsed kubectl deploy config and flag selectors; any non-nil error from that constructor (invalid kubeContext, malformed flags, artifact issues) is wrapped here.","commonSituations":"Invalid `deploy.kubectl.flags` in skaffold.yaml; unsupported/renamed kubectl flag; corrupted kubeconfig referenced by the kube-context; running `skaffold apply` on a config last written by a different Skaffold version.","solutions":["Read the inner `%w` error to identify the concrete constructor failure","Fix the deploy.kubectl section of skaffold.yaml (flags, kube-context)","Run `skaffold config list` / `kubectl config get-contexts` to verify the kube-context exists","Upgrade or match the Skaffold version used to author the config"],"exampleFix":"// before\ndeploy:\n  kubectl:\n    flags:\n      apply: [\"--unknown-flag\"]\n// after\ndeploy:\n  kubectl:\n    flags:\n      apply: [\"--server-side\"]","handlingStrategy":"validation","validationCode":"// pre-check kubectl deploy config before apply\nconst k = cfg.deploy?.kubectl\nif (k?.flags?.apply || k?.flags?.delete || k?.flags?.global) {\n  for (const f of [...(k.flags.apply||[]), ...(k.flags.delete||[]), ...(k.flags.global||[])])\n    if (!f.startsWith('--')) throw new Error(`invalid kubectl flag: ${f}`)\n}\nif (k?.kubeContext && !knownContexts.includes(k.kubeContext)) throw new Error(`unknown kube-context: ${k.kubeContext}`)","typeGuard":"function hasValidKubectlConfig(c) {\n  return c != null && typeof c === 'object' &&\n    (c.kubectl == null || typeof c.kubectl === 'object')\n}","tryCatchPattern":"deployer, err := kubectl.NewDeployer(dCtx, labeller, k, artifacts, \"\", selectors)\nif err != nil {\n    log.Errorf(\"kubectl deployer init failed: %v\", err)\n    return fmt.Errorf(\"check deploy.kubectl config: %w\", err)\n}","preventionTips":["Validate skaffold.yaml with `skaffold verify`/lint before apply","Keep kubectl flags minimal and documented in skaffold.yaml","Pin Skaffold version in CI to match config schema"],"tags":["kubectl","deployer","config","skaffold"],"backgroundTag":"deployer-init-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}