Skip to content

chore(templating): drop glued-separator workaround for chart v3#32185

Open
texasich wants to merge 2 commits into
helm:mainfrom
texasich:cleanup/yaml-v2-chart-v3
Open

chore(templating): drop glued-separator workaround for chart v3#32185
texasich wants to merge 2 commits into
helm:mainfrom
texasich:cleanup/yaml-v2-chart-v3

Conversation

@texasich

@texasich texasich commented Jun 5, 2026

Copy link
Copy Markdown

Refs #32036.

Rebased version of #32062 (original closed by author after inactivity; this is the refreshed implementation on current main).

Saw this one sitting open and figured it was a good small cleanup. The scope in the issue is pretty contained so I kept the diff to one package.

What

Tightens SplitManifests in internal/release/v2/util (the chart v3 path) so it no longer silently splits a --- that's glued to content. The regex now requires --- to be alone on a line — optional trailing spaces/tabs, then a newline or end of stream — before it counts as a document separator.

Input like:

---apiVersion: v1
kind: Service

(which is what {{- include ... }} after --- produces) used to be split back into two documents by the regex ---\s*. With this change it stays on the document body and the downstream YAML parser can surface the problem — which is exactly the point of the issue.

What's NOT changed

The Chart v1/v2 path in pkg/release/v1/util/manifest.go is left alone on purpose. Per the issue, v1/v2 chart compatibility has to be preserved indefinitely — a huge number of charts rely on the silent correction and breaking them would be a nasty regression. The strict behaviour is a v3-only, opt-in thing.

Tests

Updated TestSplitManifests in the v2 util package: the four existing "glued separator" cases now assert that the glued ---<content> stays as part of the same document. Added a few extra cases to pin down the edges:

  • --- at end of input with no trailing newline still counts as a separator
  • --- with trailing spaces/tabs still counts
  • CRLF line endings still split

go test ./internal/release/... ./pkg/release/... is green. Build and vet pass.

A follow-up migration note for the v2 → v3 guide on helm-www would be worth adding; happy to do that separately if a maintainer wants.

AI disclosure

This contribution was prepared with assistance from an AI coding agent (Hermes Agent). The human reviewed the diff, verified tests locally, performed the rebase, and is responsible for the changes.

texasich added 2 commits June 4, 2026 19:28
For chart apiVersion v3, tighten SplitManifests so it no longer silently
splits `---` glued to content (as happens when `{{-` trims the newline
after `---`). The Chart v1/v2 path in pkg/release/v1/util keeps the
lenient behaviour for backwards compatibility.

The regex now requires `---` to be alone on a line (optional trailing
horizontal whitespace, then newline or end of stream) before it counts as
a document separator. Glued input like `---apiVersion: v1` stays on the
document body so downstream YAML parsing surfaces the problem, matching
standard Go template semantics for `{{-`.

Refs helm#32036

Signed-off-by: texasich <texasich@users.noreply.github.com>
Signed-off-by: texasich <texasich@users.noreply.github.com>
@pull-request-size pull-request-size Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 5, 2026
@texasich texasich marked this pull request as ready for review June 5, 2026 00:32
Copilot AI review requested due to automatic review settings June 5, 2026 00:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR tightens Chart API v3 manifest splitting semantics by treating YAML separators glued to content as part of the document, and expands tests to cover additional separator edge-cases (trailing separators, whitespace, CRLF).

Changes:

  • Make SplitManifests use a stricter YAML document separator regex aligned with Chart API v3 behavior.
  • Update/rename existing tests to assert glued separators are not split.
  • Add new tests for trailing separators, trailing horizontal whitespace, and CRLF line endings.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
internal/release/v2/util/manifest.go Stricter separator regex + updated Chart v3 behavior documentation.
internal/release/v2/util/manifest_test.go Updates expectations for glued separators and adds new edge-case tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to +47
// sep matches YAML document separators. A separator is `---` at the start of
// a line (or start of the stream), optionally followed by trailing horizontal
// whitespace, and then a newline or end of stream.
//
// This is intentionally stricter than the Chart v1/v2 regex in
// pkg/release/v1/util/manifest.go. The v1/v2 version tolerates
// `---<non-whitespace>` (e.g. `---apiVersion: v1`) by treating it as a
// separator glued to content — a silent correction for Go template whitespace
// trimming (`{{-`) eating the newline after `---`. Chart v3 does not carry
// that workaround forward; see the function comment below.
var sep = regexp.MustCompile("(?:^|\\s*\n)---[ \\t]*(?:\\r?\\n|$)")
@promptless-for-oss

Copy link
Copy Markdown

📝 Documentation Update

I've updated the docs to cover this Chart v3 template separator behavior change.

Docs PR: helm/helm-www#2083

The migration guide (docs/topics/chart_v2_v3_migration.md) now references this PR and explains how the stricter YAML document separator handling affects chart authors upgrading to Chart v3.


🤖 Generated with Promptless

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants