Skip to content

Fix kyaml merge2: $patch directives ignored with ListPrepend - #6214

Open
saitejabandaru-in wants to merge 1 commit into
kubernetes-sigs:masterfrom
saitejabandaru-in:fix-6146-kyaml-merge2-listprepend
Open

Fix kyaml merge2: $patch directives ignored with ListPrepend#6214
saitejabandaru-in wants to merge 1 commit into
kubernetes-sigs:masterfrom
saitejabandaru-in:fix-6146-kyaml-merge2-listprepend

Conversation

@saitejabandaru-in

Copy link
Copy Markdown

Fixes #6146.

When using merge2.MergeStrings with ListIncreaseDirection: MergeOptionsListPrepend, strategic merge patch directives ($patch: replace, $patch: delete) on individual list elements were silently ignored.

The root cause was in kyaml/yaml/walk/associative_sequence.go where appendListNode(itemsToBeAdded, dest, ...) was called. Because dest contained the original unmerged items, appending dest into itemsToBeAdded (which contained the correctly merged items) caused the merged elements to be overwritten by the original elements.

This fix properly updates dest with itemsToBeAdded (the merged items) first so that the patches are applied. Then it applies the fully patched dest to itemsToBeAdded to correctly prepend the new items while retaining the patch updates.

@linux-foundation-easycla

Copy link
Copy Markdown

CLA Missing ID

  • ❌ The email address for the commit (d0144fd) is not linked to the GitHub account, preventing the EasyCLA check. Consult this Help Article and GitHub Help to resolve. (To view the commit's email address, add .patch at the end of this PR page's URL.) For further assistance with EasyCLA, please visit our EasyCLA portal and chat with our support bot.

@kubernetes-prow kubernetes-prow Bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 6, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @saitejabandaru-in. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions 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.

@kubernetes-prow kubernetes-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 6, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: saitejabandaru-in
Once this PR has been reviewed and has the lgtm label, please assign koba1t for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Labels

cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kyaml merge2: $patch directives on list elements ignored with ListPrepend

1 participant