Regression in v4.2.0: `helm template --output-dir` writes an extra trailing newline per document that v4.1.x did not
What happened?
Starting with Helm v4.2.0, helm template --output-dir <dir> writes each rendered manifest with an extra trailing newline at end-of-file compared to v4.1.x. Stdout output of helm template (without --output-dir) is unchanged across v4.1.0, v4.1.3, and v4.2.0. The regression is confined to the file-writing path.
What did you expect to happen?
helm template --output-dir to produce byte-identical output between minor versions, the same way the stdout form does.
How to reproduce it
Minimal chart with a single template:
mkdir -p /tmp/minichart/templates
cat > /tmp/minichart/Chart.yaml <<'YAML'
apiVersion: v2
name: minichart
version: 0.1.0
appVersion: "1.0.0"
YAML
cat > /tmp/minichart/values.yaml <<'YAML'
name: demo
YAML
cat > /tmp/minichart/templates/configmap.yaml <<'YAML'
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.name }}
data:
key: value
YAMLRender with each version and compare:
for v in v4.1.0 v4.1.3 v4.2.0; do
rm -rf "out-$v"
"helm-$v" template demo /tmp/minichart --output-dir "out-$v" >/dev/null
echo "$v: $(wc -c < out-$v/minichart/templates/configmap.yaml) bytes"
od -c "out-$v/minichart/templates/configmap.yaml" | tail -2
doneResult:
v4.1.0: 122 bytes
0000160 e y : v a l u e \n
v4.1.3: 122 bytes
0000160 e y : v a l u e \n
v4.2.0: 123 bytes
0000160 e y : v a l u e \n \ndiff out-v4.1.3/minichart/templates/configmap.yaml out-v4.2.0/minichart/templates/configmap.yaml shows the single extra blank line at EOF.
The same +1-byte trailing-newline shift reproduces on a multi-document template file (one \n\n at EOF instead of one \n).
The stdout form is unaffected:
for v in v4.1.0 v4.1.3 v4.2.0; do "helm-$v" template demo /tmp/minichart | wc -c; done
# 122
# 122
# 122So the regression is in whichever code path writes the per-document file under --output-dir, not in the template engine.
Helm version
$ helm-v4.1.0 version --short
v4.1.0+g4553a0a
$ helm-v4.1.3 version --short
v4.1.3+gc94d381
$ helm-v4.2.0 version --short
v4.2.0+g0646808Kubernetes version
Not relevant (no cluster involved; helm template only).
OS
Reproduced on macOS arm64 (Darwin 25.4.0). Binaries downloaded from https://get.helm.sh/.
Source: helm/helm