Skip to content

fix: do not treat consecutive groups of 3 dashes in a line as document separators#31936

Closed
marvin-roesch wants to merge 2 commits into
helm:mainfrom
marvin-roesch:fix/doc-separator-within-line
Closed

fix: do not treat consecutive groups of 3 dashes in a line as document separators#31936
marvin-roesch wants to merge 2 commits into
helm:mainfrom
marvin-roesch:fix/doc-separator-within-line

Conversation

@marvin-roesch

@marvin-roesch marvin-roesch commented Mar 13, 2026

Copy link
Copy Markdown

What this PR does / why we need it:
Fixes #31935. We consume all remaining dashes after encountering --- that is not at the start of a line such that the next iteration does not treat a --- preceded by another --- as another document separator because it appears to be at the start of the remaining content.

Note that there conceivably could be contrived scenarios where this logic fails. However, this errs on the side of realistic scenarios, as recovering the original intent from whitespace-trimmed output is generally ambiguous.

The following template demonstrates this ambiguity fully:

---
{- if true -}
---key: value
{- end -}
---
another-doc-key: value

After whitespace trimming, it would like this:

------key: value---another-doc-key: value

Both by the current fix logic implemented in #31868 and this new one, this would get reconstructed as follows:

---
---
key: value---
another-doc-key: value

I am not sure there is a good way to resolve such ambiguities in an elegant way.

Copilot AI review requested due to automatic review settings March 13, 2026 07:54
@pull-request-size pull-request-size Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 13, 2026

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

This PR refines Helm’s rendered-manifest post-processing to avoid misinterpreting consecutive --- groups that appear within a line (e.g., in script output or values) as YAML document separators, addressing the reported regression in #31935.

Changes:

  • Update fixDocSeparators to consume all consecutive - characters after a non-line-start ---, preventing the next scan from treating leftover dashes as a line-start separator.
  • Add a regression test ensuring multiple --- groups in a value (e.g., ---------value) are not treated as document separators.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/action/action.go Adjusts the doc-separator fix-up logic to skip consecutive dashes when --- is not at the start of a line.
pkg/action/action_test.go Adds a targeted regression test for consecutive triple-dash groups within a value.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread pkg/action/action_test.go
Co-authored-by: Terry Howe <[email protected]>
Signed-off-by: Marvin Rösch <[email protected]>
Copilot AI review requested due to automatic review settings March 13, 2026 12:36

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

Fixes a regression in fixDocSeparators where consecutive --- groups occurring mid-line (e.g., in values or script output) could be misinterpreted as YAML document separators after earlier processing.

Changes:

  • Update fixDocSeparators to consume all consecutive - characters when a found --- is not at the start of a line, preventing subsequent iterations from treating remaining dashes as a separator.
  • Add test cases covering multiple consecutive triple-dash groups in values and a block scalar containing long dash sequences.

Reviewed changes

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

File Description
pkg/action/action.go Adjusts separator-fix logic to avoid misclassifying contiguous dash runs mid-line as document separators.
pkg/action/action_test.go Adds regression tests ensuring mid-line dash runs and block-scalar content remain unchanged.

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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread pkg/action/action_test.go
Comment on lines +463 to +465
name: "block scalar with dashes in quoted string",
input: "---\napiVersion: v1\nkind: ConfigMap\ndata:\n script.sh: |\n echo \"------------------------------------\"\n",
expected: "---\napiVersion: v1\nkind: ConfigMap\ndata:\n script.sh: |\n echo \"------------------------------------\"\n",
@stefanprodan

Copy link
Copy Markdown

Please hold merging this, we've found the regex from Helm v1 that does the right thing when splitting ---.

@matheuscscp

Copy link
Copy Markdown
Contributor

Please hold merging this, we've found the regex from Helm v1 that does the right thing when splitting ---.

Here: #31941

@marvin-roesch

Copy link
Copy Markdown
Author

Closing this in favour of the proper fix.

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

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression for templates containing consecutive groups of 3 dashes after document separator fix

5 participants