{"record":{"id":"3cdf2a643863635b","repo":"GoogleContainerTools/skaffold","slug":"collecting-helm-releases-namespaces-w","errorCode":null,"errorMessage":"collecting helm releases namespaces: %w","messagePattern":"collecting helm releases namespaces: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/util/namespaces.go","lineNumber":55,"sourceCode":"\t\tconfig, err := kubectx.CurrentConfig()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"getting k8s configuration: %w\", err)\n\t\t}\n\n\t\tcontext, ok := config.Contexts[config.CurrentContext]\n\t\tif ok {\n\t\t\tnsMap[context.Namespace] = true\n\t\t} else {\n\t\t\tnsMap[\"\"] = true\n\t\t}\n\t} else {\n\t\tnsMap[configNamespace] = true\n\t}\n\n\t// Set additional namespaces each helm release referenced\n\thelmReleasesNamespaces, err := collectHelmReleasesNamespaces(pipelines)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"collecting helm releases namespaces: %w\", err)\n\t}\n\tfor _, namespace := range helmReleasesNamespaces {\n\t\tnsMap[namespace] = true\n\t}\n\n\t// Collate the slice of namespaces.\n\tnamespaces := make([]string, 0, len(nsMap))\n\tfor ns := range nsMap {\n\t\tnamespaces = append(namespaces, ns)\n\t}\n\n\tsort.Strings(namespaces)\n\treturn namespaces, nil\n}\n\nfunc collectHelmReleasesNamespaces(pipelines []latest.Pipeline) ([]string, error) {\n\tvar namespaces []string\n\tfor _, cfg := range pipelines {","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/util/namespaces.go#L37-L73","documentation":"This error is returned by GetAllPodNamespaces when collecting the namespaces referenced by Helm releases in the skaffold pipelines fails. It wraps the error from collectHelmReleasesNamespaces, which in practice means a templated helm release namespace could not be expanded (see error 252). Skaffold re-wraps it to give context that the failure occurred while building the list of namespaces to watch.","triggerScenarios":"Calling GetAllPodNamespaces with pipelines whose Deploy.LegacyHelmDeploy releases declare a Namespace field that contains an env/template expression (e.g. {{.NAMESPACE}}) referencing an unset variable or otherwise failing template expansion.","commonSituations":"A skaffold.yaml helm release uses `namespace: {{.MY_NAMESPACE}}` but the environment variable is not exported in the shell/CI environment; typos in template variable names; moving a working config to a new environment where required env vars are missing.","solutions":["Export the environment variable referenced in the helm release namespace template (e.g. `export MY_NAMESPACE=myns`).","Replace the templated namespace in skaffold.yaml with a literal namespace string.","Verify all template expressions in helm release namespaces resolve by checking the underlying ExpandEnvTemplateOrFail error in the wrapped output.","Move the namespace definition into the helm chart values instead of the release namespace field."],"exampleFix":"// skaffold.yaml before\nreleases:\n  - name: myrelease\n    namespace: {{.RELEASE_NAMESPACE}} # unset env var\n// after\nreleases:\n  - name: myrelease\n    namespace: mynamespace","handlingStrategy":"validation","validationCode":"// Verify every templated helm release namespace resolves before calling\nfor _, cfg := range pipelines {\n\tif cfg.Deploy.LegacyHelmDeploy != nil {\n\t\tfor _, r := range cfg.Deploy.LegacyHelmDeploy.Releases {\n\t\t\tif r.Namespace != \"\" {\n\t\t\t\tif _, err := util.ExpandEnvTemplateOrFail(r.Namespace, nil); err != nil {\n\t\t\t\t\tlog.Printf(\"namespace template %q cannot expand: %v\", r.Namespace, err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}","typeGuard":null,"tryCatchPattern":"namespaces, err := util.GetAllPodNamespaces(ns, pipelines)\nif err != nil && strings.Contains(err.Error(), \"collecting helm releases namespaces\") {\n\treturn fmt.Errorf(\"helm release namespace config invalid: %w\", err)\n}","preventionTips":["Prefer literal namespace strings in helm release entries.","Set all referenced env vars in CI and shell profiles before running skaffold.","Keep release namespace templates limited to simple {{.VAR}} env references.","Test skaffold.yaml changes in an environment mirroring CI env vars."],"tags":["helm","namespace","template","skaffold-yaml"],"backgroundTag":"template-variable-unset","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"}