Conversation
|
This PR has multiple commits, and the default merge method is: merge. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: somaz94 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @somaz94! |
|
Hi @somaz94. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
kustomize editpreviously collected all lines starting with#as field comments, regardless of indentation, causing lines inside YAML block scalars (|,>) to be misinterpreted as comments. This caused those lines to be duplicated on each run and inserted before the following field. This PR introduces indentation tracking for block scalar headers so lines inside a block scalar are recognized as content rather than field comments.Rationale
Editing a
kustomization.yamlthat contains multiline scripts or configs inside block scalars should be idempotent. Previously, runningkustomize editmultiple times duplicated#lines exponentially, changing unrelated transformer content and growing the file without limit.Related issue
Fixes #6225
While #4481 addresses the broader problem of comment placement and movement across fields, this fix specifically addresses content corruption caused by mistaking block scalar content for field comments.
Assignment and coordination
Assigned via
/assignon 2026-09-22 in #6225 (comment) prior to starting the implementation.Testing
kustomizationfile_test.gothat pins the current incorrect output, where#lines inside a block scalar are moved above the field and duplicated.kustomizationfile.goand updated the test to expect the input unchanged after a write, which also makes repeated edits idempotent.go test ./kustomize/commands/internal/kustfile/... -v(all tests passed).golangci-lintwith the repo config reports 0 issues, and the reproduction script from the issue keeps the marker count at 1 across 5 runs.AI disclosure
I used Anthropic Claude Code (Claude Opus 5) to trace the root cause, write the fix and the regression test, and run the local checks. It also helped with light edits to this description. I reviewed the full diff and the test results, and wrote the commit messages and this description myself.