temporalio / temporalio/temporal

Review/Improve Startup Config Template Rendering Code/Process using Sprig

Open
#10,663 0 comments 0 reactions 1 assignee View on GitHub

@fretz12 is already working on this.

Since Jun 11, 2026.

enhancement
Dominant language
Go
Stars
23.2k
Forks
1.9k
Avg merge
2d 8h
Merged PRs (30d)
228

Description

Is your feature request related to a problem? Please describe.

At startup, the config loader reads files from $TEMPORAL_ROOT/config/ (default: config/) in precedence order — base.yaml, {env}.yaml, {env}_{zone}.yaml — or a single file specified by TEMPORAL_SERVER_CONFIG_FILE_PATH. For each file, the loader scans the first 1KB for # enable-template (loader.go:51, loader.go:273) to decide whether to render it as a Go/Sprig template. This approach has several silent failure modes:

  • A typo like # enable-templates or a comment like # do-not-enable-template silently mis-triggers or disables rendering. A file full of {{ env "VAR" }} with a missing or misspelled comment loads as literal YAML with no clear error.
  • A long header comment can push # enable-template past the 1KB scan window, silently disabling templating.
  • strings.Contains matches any comment containing the substring enable-template, including unrelated comments like # to render this template using sprig add a comment as follows: # enable-template.

Describe the solution you'd like

Always render config files through the Go/Sprig template engine. Plain YAML passes through unchanged, so there is no downside. The change eliminates bugs and reduces code complexity:

What is removed Location Lines Removed
enableTemplate, commentSearchLimit constants loader.go:51–52 2
bufio, io imports loader.go:4–5 2
checkTemplatingEnabled call + guard in processConfigFile loader.go:228–237 10
checkTemplatingEnabled function (cyclomatic complexity: 3) loader.go:268–279 12
Total 26

I'd be happy to submit a pull request for this change if the approach is agreeable.

Describe alternatives you've considered

  • Use a .yaml.tmpl extension to signal templated files — unambiguous and consistent with common convention.
  • Add an explicit --config-templated flag or TEMPORAL_CONFIG_TEMPLATE_RENDER_WITH_SPRIG env var (default true).

Additional context

Relevant code in common/config/loader.go:

  • Lines 51–52: enableTemplate, commentSearchLimit constants
  • Lines 227–252: processConfigFile
  • Lines 268–279: checkTemplatingEnabled

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.