fix: nomad template whitespace trimming strips newlines between env var blocks (#996) #1006
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#1006
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-996"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #996
Changes
AI Review
Claim
The fix does not change the rendered template output. Go's
text/template(used by consul-template/Nomad) strips all trailing whitespace from the preceding text node when a{{-prefix is encountered. Adding\n\nbetween{{- end }}and{{- withproduces identical rendered output to the original\n— both are fully consumed by the leading trim onwith. The env var concatenation bug persists at runtime.Root-cause blocker
critical
nomad/jobs/agents.hcl,nomad/jobs/vault-runner.hcl: The separator added between blocks is\n\n(after{{- end }}) followed by{{- with. The{{-trim marker onwithcallsstrings.TrimRighton the preceding text node, removing all whitespace characters regardless of count. One\nor two\n\n— both collapse to an empty string. The next env var block starts immediately after the last non-whitespace character of the previous block.Trace for else branch (secret not seeded):
{{- else -}}trims the\nafter the with-branch's last line and the\nbefore the else-branch's first lineFORGE_PASS=seed-meoutputs; the trailing\nbefore{{- end }}is trimmed by{{-on end{{- end }}, text node\n\nexists but is then fully trimmed by{{- withon the next blockFORGE_PASS=seed-meFORGE_REVIEW_TOKEN=seed-me— still concatenated on one lineSame problem on the taken branch:
{{- else -}}trims the\nafter the last env var line, so the with-branch also ends without a trailing newline.Fix
Remove the leading
-from{{- withon every block after the first — change to{{ with secret ... -}}. The blank line between{{- end }}and{{ withis then a literal text node that is not trimmed, and it emits\ninto the rendered env file.Example corrected form:
The
{{-on the first block (bots/dev/GITHUB_TOKEN) can stay to suppress the leading newline at the top of the heredoc. All subsequent blocks should use{{ withso the blank-line separator survives rendering.Verdict
REQUEST_CHANGES — Blank lines between {{- end }} and {{- with are fully consumed by the leading trim marker; rendered output is unchanged from pre-fix
Reviewed at
1a43227| AGENTS.mdAI Review: REQUEST_CHANGES — Blank lines between {{- end }} and {{- with are fully consumed by the leading trim marker; rendered output is unchanged from pre-fix
1a43227f11tod8f2be1c4fAI Re-review (round 2)
Previous Findings
{{- withtrim markers consume blank-line separators → FIXED: all inter-blockwithtags changed to{{ with(no leading trim); blank-line text node between{{- end }}and{{ withis now emitted, separating env var blocks in the rendered outputVerification
Trace for else branch:
{{- end }}trims trailing\nfrom preceding value; text node\n\nfollows with no leading-on{{ with, so\n\nemits into the env file;{{ with ... -}}trims only the\nafter the opening tag. Result:PREV=seed-me\n\nNEXT=seed-me. Same for taken branch. Both files (agents.hcl,vault-runner.hcl) updated consistently across all 12 inter-block stanzas.The
bin/disintohunks in the incremental diff are carry-over from #1004 (already in main); they net to zero in the full diff.Verdict
APPROVE — Removed leading - from all inter-block with tags; blank-line separator now survives rendering
Reviewed at
d8f2be1| Previous:1a43227| AGENTS.mdAI Re-review (round 2): APPROVE — Removed leading - from all inter-block with tags; blank-line separator now survives rendering