You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
kyaml merge2: $patch directives on list elements ignored with ListPrepend #6146
When using merge2.MergeStrings with MergeOptions{ListIncreaseDirection: MergeOptionsListPrepend}, strategic merge patch directives ($patch: replace, $patch: delete) on individual associative list elements are silently ignored.
With default MergeOptions{} (Append), $patch: replace correctly replaces the matched list element. With ListPrepend, the original element remains unchanged and the replacement is dropped.
Root cause
In kyaml/yaml/walk/associative_sequence.go, setAssociativeSequenceElements() assembles the final list differently depending on the merge direction:
Append (correct): appendListNode(dest, itemsToBeAdded, ...); merged results from itemsToBeAdded overwrite originals in dest.
ListPrepend (buggy): appendListNode(itemsToBeAdded, dest, ...); the arguments are swapped for ordering, but this causes ElementSetter to overwrite already-merged items in itemsToBeAdded with the unmerged originals from dest, undoing $patch directive effects.
This bug prevents combining ListPrepend (for controlling list item ordering) with $patch: replace or $patch: delete (for replacing/removing individual items by merge key). The two features are independent and should compose correctly IMHO.
SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the triage/accepted label.
The triage/accepted label can be added by org members by writing /triage accepted in a comment.
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.
changed the title [-]kyaml merge2: $patch directives on list elements ignored with ListPrepend[/-][+]kyaml merge2: `$patch` directives on list elements ignored with `ListPrepend`[/+]on May 12, 2026
This is not limited to direct kyaml users: api/filters/patchstrategicmerge merges with MergeOptionsListPrepend, so plain kustomize build hits it too. With this base and patch:
Unassigning myself — @rm3l had #6147 open for this well before I picked it up, and I missed
it. #6265 stays open in case the maintainers find it useful, but this one is not mine to hold.
Activity
k8s-ci-robot commentedon May 12, 2026
This issue is currently awaiting triage.
SIG CLI takes a lead on issue triage for this repo, but any Kubernetes member can accept issues by applying the
triage/acceptedlabel.The
triage/acceptedlabel can be added by org members by writing/triage acceptedin a comment.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.
[-]kyaml merge2: $patch directives on list elements ignored with ListPrepend[/-][+]kyaml merge2: `$patch` directives on list elements ignored with `ListPrepend`[/+]rm3l commentedon May 12, 2026
/kind bug
jang-hs commentedon Sep 11, 2026
This is not limited to direct kyaml users:
api/filters/patchstrategicmergemerges withMergeOptionsListPrepend, so plainkustomize buildhits it too. With this base and patch:kustomize v5.8.x emits the original container untouched — the patch is silently a no-op.
#5255 looks like the same thing reported from the CLI side.
/assign
jang-hs commentedon Sep 11, 2026
Unassigning myself — @rm3l had #6147 open for this well before I picked it up, and I missed
it. #6265 stays open in case the maintainers find it useful, but this one is not mine to hold.
/unassign