Skip to content

bug(chart): extraTemplateManifests silently drops every document after the first #667

Description

@Vad1mo

Summary

deploy/chart/templates/extraManifests.yaml pipes each extraTemplateManifests entry through fromYaml, which parses only the first YAML document in a string. Every document after the first --- separator is discarded silently — no error, no warning, and the rendered output looks well-formed.

Since extraManifests is the escape hatch for resources the chart does not model, a user grouping several related objects into one entry loses all but one of them, and will typically only find out when something downstream is missing.

Cause

deploy/chart/templates/extraManifests.yaml:22
{{- $rendered := tpl . $ | fromYaml }}

fromYaml is single-document by definition. The multi-document case needs splitting before parsing.

Reproduce

extraTemplateManifests:
  - |
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: first
    ---
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: second

helm template emits only first. second is gone, with no diagnostic.

Why it survived

deploy/chart/tests/extramanifests_test.yaml covers the single-document cases well — static pass-through, tpl() interpolation, and the empty case — but there is no multi-document case in the suite. A regression test feeding one entry containing two documents and asserting both are rendered would pin this.

Two related problems in the same file

A string entry in extraManifests fails hard. The static branch does deepCopy . at line 10 and then reads $manifest.metadata at line 11, so a string entry aborts rendering with wrong type for value; expected map[string]interface{}; got string. Worth either accepting strings there for symmetry with extraTemplateManifests, or documenting that the static list is maps-only.

Chomping after the separators. Lines 10 and 22 open with {{- immediately after a --- line, which trims the newline and yields ---apiVersion: v1 on a single line in the raw render. Currently harmless, because Helm's document splitter matches (?m)^---, but it is one edit away from breaking and makes the raw output awkward to read.

Suggested fix

Split the rendered string on the document separator before parsing, and handle each document individually. 8gears/n8n-helm-chart implements the same escape hatch and splits on --- before templating, so it handles the multi-document case correctly — useful as a reference.

Worth noting the comparison runs the other way too: this chart's label handling is the better of the two. It uses deepCopy so it does not mutate .Values, and it merges user labels under app.kubernetes.io/*, where the n8n chart stamps the Helm 2 legacy scheme.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions