temporalio/temporal · error

failed to process config file %s: %w

Error message

failed to process config file %s: %w

What it means

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.

Source

Thrown at common/config/loader.go:257

	stdlog.Printf("Processing config file as template; filename=%v\n", filename)
	tpl, err := template.New(filename).Funcs(sprig.FuncMap()).Parse(string(data))
	if err != nil {
		return nil, err
	}

	var rendered bytes.Buffer
	err = tpl.Execute(&rendered, nil)
	if err != nil {
		return nil, err
	}

	return rendered.Bytes(), nil
}

func loadAndUnmarshalContent(content []byte, filename string, config any) error {
	processed, err := processConfigFile(content, filename)
	if err != nil {
		return fmt.Errorf("failed to process config file %s: %w", filename, err)
	}

	if err := yaml.Unmarshal(processed, config); err != nil {
		return fmt.Errorf("failed to unmarshal config file %s: %w", filename, err)
	}

	validate := newValidator()
	return validate.Validate(config)
}

func checkTemplatingEnabled(content []byte) (bool, error) {
	scanner := bufio.NewScanner(io.LimitReader(bytes.NewReader(content), commentSearchLimit))
	for scanner.Scan() {
		line := strings.TrimSpace(scanner.Text())

		if strings.HasPrefix(line, "#") && strings.Contains(line, enableTemplate) {
			return true, nil
		}

View on GitHub (pinned to bde624efd1)

Solutions

  1. Read the wrapped error (%w) to find the exact template parse/exec failure and line in the named file
  2. Fix or remove the malformed {{ ... }} expression in the config file
  3. Escape literal braces that are not template syntax, or disable template processing if unintended
  4. Confirm required env vars referenced by the template (e.g. .Env.VAR) are set in the process environment

Example fix

// before (config/temporal.yaml)
frontend:
  rpcName: {{ .Env.FRONTEND_NAME
// after
frontend:
  rpcName: {{ .Env.FRONTEND_NAME }}
Defensive patterns

Strategy: validation

Validate before calling

for _, f := range configFiles {
	data, _ := os.ReadFile(f)
	if strings.Count(string(data), "{{") != strings.Count(string(data), "}}") {
		return fmt.Errorf("unbalanced template braces in %s", f)
	}
	// optionally: template.New(f).Parse(string(data)) and surface parse errors before load
}

Try / catch

cfg, err := config.LoadConfig(env, configDir, zone)
if err != nil {
	var procErr *fmt.Errorf // inspect wrapped cause
	log.Fatalf("config load failed: %v; check template syntax in config files: %v", err, errors.Unwrap(err))
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/b3115dafd715fd30. Report an issue: GitHub.