Skip to content

fix(helm): keep commas inside --set lists and escapes in helm_upgrade - #110

Open
lbarrosby wants to merge 1 commit into
kagent-dev:mainfrom
lbarrosby:helm-set-keep-lists
Open

lbarrosby wants to merge 1 commit into
kagent-dev:mainfrom
lbarrosby:helm-set-keep-lists

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

helm_upgrade takes set as key1=val1,key2=val2 and turns it into one --set per item with strings.Split(in.Set, ","). That also cuts the commas helm itself treats as part of a value, so two documented --set forms could not be passed through the tool:

$ helm template t demo --set 'items={a' --set 'b}'      # what the tool ran for set="items={a,b}"
Error: failed parsing --set data: list must terminate with '}'
$ helm template t demo --set 'note=a\' --set 'b'        # what the tool ran for set="note=a\,b"
Error: failed parsing --set data: key "b" has no value
$ helm template t demo --set 'items={a,b}' --set 'note=a\,b'
  items: "[\"a\",\"b\"]"
  note: "a,b"

splitSetValues now splits only on commas that are outside {...} and not escaped with \, trims each item and drops empty ones. Plain key1=val1,key2=val2 input produces the same arguments as before, so the existing "upgrade with all options" test is unchanged.

Tests: a helm_upgrade case with args={--verbose,--debug}, annotation=a\,b, replicas=2 that expects three --set flags (fails on main, where the list is split into args={--verbose and --debug}), and a table test for splitSetValues covering spaces, nested lists, escapes and empty items. go test -tags=test ./pkg/... ./internal/... ./cmd/..., go vet and golangci-lint run --build-tags=test ./pkg/helm/ pass.

AI disclosure: written with the help of Claude Code, reviewed and tested by me.

handleHelmUpgradeRelease split the set parameter on every comma, so a
list value such as tolerations={a,b} or an escaped comma (a\,b) was cut
into two --set flags and helm failed with "list must terminate with '}'"
or "key has no value". Split only on commas outside braces and not
escaped with a backslash, the same places helm's own parser splits.

Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
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.

1 participant