{"record":{"id":"fe1c16b056b47cd2","repo":"GoogleContainerTools/skaffold","slug":"cannot-parse-the-release-namespace-template-w","errorCode":null,"errorMessage":"cannot parse the release namespace template: %w","messagePattern":"cannot parse the release namespace template: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/util/namespaces.go","lineNumber":79,"sourceCode":"\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 {\n\t\tif cfg.Deploy.LegacyHelmDeploy != nil {\n\t\t\tfor _, release := range cfg.Deploy.LegacyHelmDeploy.Releases {\n\t\t\t\tif release.Namespace != \"\" {\n\t\t\t\t\ttemplatedNamespace, err := util.ExpandEnvTemplateOrFail(release.Namespace, nil)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\treturn []string{}, fmt.Errorf(\"cannot parse the release namespace template: %w\", err)\n\t\t\t\t\t}\n\t\t\t\t\tnamespaces = append(namespaces, templatedNamespace)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn namespaces, nil\n}\n","sourceCodeStart":61,"sourceCodeEnd":88,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/util/namespaces.go#L61-L88","documentation":"collectHelmReleasesNamespaces throws this when the Namespace field of a LegacyHelmDeploy release is a template that util.ExpandEnvTemplateOrFail cannot expand. Templates are expanded with the environment as the only value set (extra values passed as nil), so any {{.VAR}} must exist as an environment variable. The wrapped error names the unresolved variable.","triggerScenarios":"A helm release in skaffold.yaml defines `namespace: {{.SOME_VAR}}` (or another env-template expression) and SOME_VAR is not set in the process environment when skaffold runs, or the template syntax is malformed.","commonSituations":"CI environments missing vars set locally; undefined variables after refactoring env var names in skaffold.yaml; malformed Go template syntax like `{{NAMESPACE}}` instead of `{{.NAMESPACE}}`; using runtime-only variables not present at deploy time.","solutions":["Set the referenced environment variable before running skaffold (e.g. `export NAMESPACE=dev && skaffold run`).","Hardcode the namespace in the release entry instead of using a template.","Fix the template syntax — variables need a dot prefix: `{{.NAMESPACE}}`, not `{{NAMESPACE}}`.","Note that only environment variables are available for expansion; do not use variables from other skaffold config scopes."],"exampleFix":"// skaffold.yaml before\nreleases:\n  - name: app\n    namespace: {{NAMESPACE}} # invalid syntax / undefined\n// after\nreleases:\n  - name: app\n    namespace: {{.NAMESPACE}} # with `export NAMESPACE=dev`","handlingStrategy":"validation","validationCode":"// Validate the template resolves before invoking the deploy pipeline\nif _, err := util.ExpandEnvTemplateOrFail(release.Namespace, nil); err != nil {\n\treturn fmt.Errorf(\"helm release %q namespace %q unset: %w\", release.Name, release.Namespace, err)\n}","typeGuard":null,"tryCatchPattern":"_, err := util.GetAllPodNamespaces(ns, pipelines)\nif err != nil && strings.Contains(err.Error(), \"cannot parse the release namespace template\") {\n\tlog.Fatalf(\"set the env var referenced by the release namespace: %v\", err)\n}","preventionTips":["Use the `{{.VAR}}` dot-prefix form for all template variables.","Export required variables in shell profiles and CI pipeline definitions.","Avoid exotic template constructs (functions, conditionals) in namespace fields — only env substitution is supported.","Pin namespaces per environment via profiles rather than runtime variables."],"tags":["helm","go-template","environment-variable","namespace"],"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"}