Skip to content

Fix templating issues in computed values#71

Merged
Ilyes512 merged 3 commits into
mainfrom
fix-templating-issues-in-computed-values
May 16, 2026
Merged

Fix templating issues in computed values#71
Ilyes512 merged 3 commits into
mainfrom
fix-templating-issues-in-computed-values

Conversation

@Ilyes512
Copy link
Copy Markdown
Member

@Ilyes512 Ilyes512 commented May 16, 2026

  • Fix extractRefs using parse.New (raw parser) instead of texttemplate.New: Go builtins like eq were not registered, causing silent parse failures that broke topological sort for computed values and produced misleading map has no entry for key errors at runtime
  • Add slog.Debug to extractRefs so parse failures are visible with --debug
  • Add slog.Debug to analyseExpr for the same reason
  • Add regression test covering nested ternary with custom delimiters

Ilyes512 and others added 3 commits May 16, 2026 19:08
…ecognised

parse.New (the raw parser) does not register Go's builtin template functions
(eq, ne, and, or, not, …). When a computed value expression used one of those
builtins, extractRefs silently returned nil (parse error swallowed), the topo
sort saw no computed-key dependencies, and PhpDockerTag (or any such value)
could be scheduled before the plain-string computed values it depends on —
producing a 'map has no entry for key' error at execution time.

Fix: replace parse.New(t).Parse with texttemplate.New().Delims.Funcs.Parse,
the same path used by renderExpr, so both builtins and Sprout functions are
available to the parser.

Add a regression test that covers nested ternary with custom delimiters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously a parse failure in extractRefs was completely invisible — no log
at any level, not even with --debug. This made the root cause of topo-sort
bugs very hard to find. Now the error is emitted at slog.Debug so it shows
up when --debug is passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mirrors the same improvement made to extractRefs: parse failures in
analyseExpr were completely invisible at all log levels. A failing parse
here causes conditional-analysis to be skipped for that expression (safe,
conservative), but was impossible to diagnose. Now emits slog.Debug so
--debug surfaces the issue.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Ilyes512 Ilyes512 marked this pull request as ready for review May 16, 2026 17:18
@Ilyes512 Ilyes512 merged commit 66913e0 into main May 16, 2026
1 check passed
@Ilyes512 Ilyes512 deleted the fix-templating-issues-in-computed-values branch May 16, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant