Helm "YAML parse error on ... template" - Fix Template Output in CI
Helm rendered a template and the resulting text is not valid YAML. The Go templating produced broken indentation, an empty value where a key was expected, or an unquoted interpolated string that corrupts the document.
What this error means
helm install/template fails with Error: YAML parse error on <chart>/templates/<file>.yaml: error converting YAML to JSON: yaml: line N: <detail>. The chart’s logic is fine; the rendered output at that line is malformed.
Error: YAML parse error on api/templates/deployment.yaml: error converting YAML
to JSON: yaml: line 23: did not find expected keyCommon causes
Bad indentation from templating
A {{ .Values.x | nindent N }} with the wrong N, or a block inserted at the wrong indentation, shifts keys so the rendered YAML no longer parses.
Missing/empty value or unquoted interpolation
A value that renders empty leaves key: with nothing (or wrong structure), and an unquoted string containing : or special chars breaks the document. Numbers/strings often need | quote.
How to fix it
Render the template and read line N
See exactly what Helm produced at the failing line so you can spot the indentation or empty value.
helm template ./chart --debug 2>&1 | sed -n '18,28p'
# or render one file
helm template ./chart --show-only templates/deployment.yamlFix indentation and quote values
- Use
nindent/indentwith the correct column for inserted blocks. - Quote interpolated scalars (
{{ .Values.x | quote }}) and provide defaults ({{ .Values.x | default "..." }}) so nothing renders empty. - Lint the chart (
helm lint) and validate rendered output before install.
How to prevent it
- Run
helm lintandhelm templatein CI to catch render errors before install. - Quote interpolated values and supply defaults so templates never emit empty keys.
- Use
nindentcarefully and review rendered output for indentation drift.