Repository navigation
Description
What happened?
A --set value whose list index has no closing ] is dropped without any error, and helm template exits 0.
The same happens with --set-string, --set-json, --set-file and --set-literal.
A typo such as ingress.hosts[0.host=example.com therefore renders the chart without that value, and nothing tells the user.
keyIndex() reads up to ] and returns io.EOF when the input ends first.
key() wraps it with fmt.Errorf("error parsing index: %w", err) (pkg/strvals/parser.go:197, literal_parser.go:142).
#31649 changed parse() from err == io.EOF to errors.Is(err, io.EOF) (parser.go:164, literal_parser.go:70), so the wrapped io.EOF is now taken as the normal end of input and parse() returns nil.
Before #31649 the wrapped error did not match ==, and the user got error parsing index: EOF.
Reading the source of each tag, the errors.Is check first appears in v4.1.0; v4.0.x and v3.22.1 still use ==, so Helm 3 does not look affected.
What did you expect to happen?
An error, for example failed parsing --set data: error parsing index: missing closing ']', and a non-zero exit code.
How can we reproduce it (as minimally and precisely as possible)?
Chart ./v has one template that prints {{ toJson .Values }} and an empty values.yaml.
$ helm template d ./v --set 'image.tag=v2,ingress.hosts[0.host=example.com' # rc=0
values: "{\"image\":{\"tag\":\"v2\"}}"
$ helm template d ./v --set 'ingress.hosts[0].host=example.com' # rc=0, for comparison
values: "{\"ingress\":{\"hosts\":[{\"host\":\"example.com\"}]}}"
$ helm template d ./v --set 'a[=1' # rc=0, values: "{}"
$ helm template d ./v --set 'a[0=1' # rc=0, values: "{}"
$ helm template d ./v --set-string 'a[0=1' # rc=0, values: "{}"
$ helm template d ./v --set-json 'a[0={"k":1}' # rc=0, values: "{}"
$ helm template d ./v --set-literal 'a[0=1' # rc=0, values: "{}"
$ helm template d ./v --set-file 'a[0=f.txt' # rc=0, values: "{}"Other malformed keys are still rejected, for example:
$ helm template d ./v --set 'a[x]=1' # rc=1
Error: failed parsing --set data: error parsing index: strconv.Atoi: parsing "x": invalid syntaxHelm version
Details
$ helm version --short
v4.2.1+gd591a19I have not re-run this on v4.3.1. The lines quoted above are the same in the v4.3.1 tag and on main.
Kubernetes version
Not relevant: helm template only, no cluster access.
Anything else?
I have a small fix with tests (make keyIndex() return a dedicated error instead of io.EOF, so parse() can keep errors.Is) and can open a PR if that direction is fine.
AI disclosure: I used Claude (Anthropic) to help trace the cause and write this report. The commands above were run on my own cluster, also with Claude's help.
Activity