Skip to content

fix: keep elements added to an existing array by --state-values-set - #2873

Merged
yxxhero merged 1 commit into
helmfile:mainfrom
lbarrosby:fix/state-values-set-grow-array
Nov 6, 2026
Merged

yxxhero merged 1 commit into
helmfile:mainfrom
lbarrosby:fix/state-values-set-grow-array

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

helmfile --state-values-set 'servers[0].host=a,servers[1].host=b' template ends 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-set flags 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, so getMap stores the new element in that copy. #533 fixed the copy itself; this adds the missing m[a.key] = t.

Tested with a new TestSet_GrowsExistingArrayForNestedKey (fails on main with only one element), go test ./pkg/maputil/ passes.

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>
@yxxhero
yxxhero merged commit f21bca4 into helmfile:main Nov 6, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants