Repository navigation
fix: keep elements added to an existing array by --state-values-set - #2873
Merged
Merged
Conversation
getArray grew a copy of the slice when a nested key used an index past its end, but never stored it back in the map, so the new element was written to a throwaway copy. Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
lbarrosby
requested review from
aditmeno,
itscaro,
mumoshu,
xiaomudk,
yxxhero and
zhaque44
as code owners
November 5, 2026 02:30
yxxhero
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
helmfile --state-values-set 'servers[0].host=a,servers[1].host=b' templateends up with.Values.servers == [{host: a}]: the second element is dropped. It happens whenever a later assignment uses a higher index plus a nested key on an array that already exists (also across separate--state-values-setflags and with--state-values-set-string).In
indexedKeyArg.getArray, the grow branch builds a longer copy of the slice but never writes it back to the map, sogetMapstores the new element in that copy. #533 fixed the copy itself; this adds the missingm[a.key] = t.Tested with a new
TestSet_GrowsExistingArrayForNestedKey(fails on main with only one element),go test ./pkg/maputil/passes.