{"record":{"id":"b3115dafd715fd30","repo":"temporalio/temporal","slug":"failed-to-process-config-file-s-w","errorCode":null,"errorMessage":"failed to process config file %s: %w","messagePattern":"failed to process config file (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/config/loader.go","lineNumber":257,"sourceCode":"\tstdlog.Printf(\"Processing config file as template; filename=%v\\n\", filename)\n\ttpl, err := template.New(filename).Funcs(sprig.FuncMap()).Parse(string(data))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tvar rendered bytes.Buffer\n\terr = tpl.Execute(&rendered, nil)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn rendered.Bytes(), nil\n}\n\nfunc loadAndUnmarshalContent(content []byte, filename string, config any) error {\n\tprocessed, err := processConfigFile(content, filename)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to process config file %s: %w\", filename, err)\n\t}\n\n\tif err := yaml.Unmarshal(processed, config); err != nil {\n\t\treturn fmt.Errorf(\"failed to unmarshal config file %s: %w\", filename, err)\n\t}\n\n\tvalidate := newValidator()\n\treturn validate.Validate(config)\n}\n\nfunc checkTemplatingEnabled(content []byte) (bool, error) {\n\tscanner := bufio.NewScanner(io.LimitReader(bytes.NewReader(content), commentSearchLimit))\n\tfor scanner.Scan() {\n\t\tline := strings.TrimSpace(scanner.Text())\n\n\t\tif strings.HasPrefix(line, \"#\") && strings.Contains(line, enableTemplate) {\n\t\t\treturn true, nil\n\t\t}","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/temporalio/temporal/blob/bde624efd13fbd3843654058db6d9c716166318b/common/config/loader.go#L239-L275","documentation":"loadAndUnmarshalContent renders each config file as a Go template (when template processing is enabled) before YAML unmarshalling. Failures in that rendering step are wrapped as \"failed to process config file <name>\". Commonly the underlying cause is an invalid template expression such as an unbalanced {{ }} or a failing env lookup in the template.","triggerScenarios":"load -> loadAndUnmarshalContent where processConfigFile errors: typically a malformed Go template in the YAML (bad {{ .Env.X }} syntax, unclosed action, or template function error) — note unmarshal failures use a different message.","commonSituations":"Users substituting environment variables in config YAML with {{ .Env.FOO }} and misquoting/unclosing braces, pasting content containing literal {{ }} that is not intended as template syntax, or a template helper failing for a missing env var depending on loader options.","solutions":["Read the wrapped error (%w) to find the exact template parse/exec failure and line in the named file","Fix or remove the malformed {{ ... }} expression in the config file","Escape literal braces that are not template syntax, or disable template processing if unintended","Confirm required env vars referenced by the template (e.g. .Env.VAR) are set in the process environment"],"exampleFix":"// before (config/temporal.yaml)\nfrontend:\n  rpcName: {{ .Env.FRONTEND_NAME\n// after\nfrontend:\n  rpcName: {{ .Env.FRONTEND_NAME }}","handlingStrategy":"validation","validationCode":"for _, f := range configFiles {\n\tdata, _ := os.ReadFile(f)\n\tif strings.Count(string(data), \"{{\") != strings.Count(string(data), \"}}\") {\n\t\treturn fmt.Errorf(\"unbalanced template braces in %s\", f)\n\t}\n\t// optionally: template.New(f).Parse(string(data)) and surface parse errors before load\n}","typeGuard":null,"tryCatchPattern":"cfg, err := config.LoadConfig(env, configDir, zone)\nif err != nil {\n\tvar procErr *fmt.Errorf // inspect wrapped cause\n\tlog.Fatalf(\"config load failed: %v; check template syntax in config files: %v\", err, errors.Unwrap(err))\n}","preventionTips":["Test-render config templates locally with the same env vars used in deployment","Escape literal {{ }} in YAML with {{ \"{{\" }} or avoid them entirely","Keep a smoke test that loads all config files for each environment in CI"],"tags":["config","template","yaml"],"backgroundTag":"config-template-render-failed","analyzedSha":"bde624efd13fbd3843654058db6d9c716166318b","analyzedAt":"2026-09-01T07:18:39.080Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}