`Error: YAML parse error on shop/templates/api-deployment.yaml: error converting YAML to JSON: yaml: line 31: did not find expected key`
BeginnerTroubleshootingTemplating & Rendering Errors
Answer
Likely causes → Wrong indentation in the rendered output: indent instead of nindent, a wrong number, or {{- that ate a newline. The line number refers to the rendered document, not the template.
Diagnose →
helm template shop ./shop -f values-prod.yaml -s templates/api-deployment.yaml --debug | cat -n | sed -n '25,35p'
Fix → Use the pattern key: on its own line followed by {{- toYaml .Values.x | nindent N }} with N equal to the key's indentation plus two.
Prevent → Render all templates in CI with every environment's values; unit tests on tricky blocks.
More on Templating & Rendering Errors
`Error: template: shop/templates/api-deployment.yaml:24:28: executing "shop/templates/api-deployment.yaml" at <.Values.api.image.tag>: nil pointer evaluating interface {}.tag`Beginner`Error: YAML parse error on shop/templates/configmap.yaml: error converting YAML to JSON: yaml: line 7: mapping values are not allowed in this context`Intermediate`Error: template: shop/templates/api-deployment.yaml:18:12: executing "..." at <include "shop.labels" .>: error calling include: template: no template "shop.labels" associated with template "gotpl"`Beginner`Error: template: shop/templates/_helpers.tpl:14:14: executing "shop.fullname" at <.Chart.Name>: can't evaluate field Chart in type string`Intermediate`Error: parse error at (shop/templates/api-deployment.yaml:40): function "toYml" not defined`Beginner`Error: parse error at (shop/templates/ingress.yaml:42): unexpected {{end}}` or `unexpected EOF`Beginner