Skip to content

Fix MergeYaml Document.End fallback inserting extra blank lines#7311

Merged
timtebeek merged 1 commit intomainfrom
fix/merge-yaml-document-end-fallback
Apr 7, 2026
Merged

Fix MergeYaml Document.End fallback inserting extra blank lines#7311
timtebeek merged 1 commit intomainfrom
fix/merge-yaml-document-end-fallback

Conversation

@timtebeek
Copy link
Copy Markdown
Member

Summary

  • Fix the Document.End prefix fallback in MergeYamlVisitor.mergeMapping() to only use the prefix when it actually contains a YAML comment (# character)
  • The fallback introduced in Fix MergeYaml wildcard, flow-style sequence, and comment handling #7291 would copy plain trailing whitespace (e.g. a bare \n) as a "comment" onto newly merged entries, causing an extra blank line in the output
  • This caused SeparateApplicationYamlByProfileTest.mergeIntoExistingProfileFilePreservesFormat to fail in openrewrite/rewrite-spring CI

Test plan

The Document.End prefix fallback introduced in #7291 would copy
trailing whitespace (e.g. a bare newline) as a "comment" prefix
onto newly merged entries, causing an extra blank line in the output.

Only use the Document.End prefix when it actually contains a YAML
comment (has a `#` character). Plain trailing whitespace should not
be treated as a comment to preserve.

Fixes the `SeparateApplicationYamlByProfileTest.mergeIntoExistingProfileFilePreservesFormat`
failure in openrewrite/rewrite-spring.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Apr 7, 2026
@timtebeek timtebeek merged commit b0f88bc into main Apr 7, 2026
1 check passed
@timtebeek timtebeek deleted the fix/merge-yaml-document-end-fallback branch April 7, 2026 19:51
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant