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
Helm converts integers to scientific notation even when quoted #3001
Our build uses git commit hashes for container tags during the build and then runs our helm chart tests using all the build containers for that specific commit. We had an instance this morning where the tag was completely numeric. As such, the tag got converted to scientific notation.
And observe the following status on the resulting pod: "InvalidImageName"
What I expected to happen
I understand type coercion between all these sources can be difficult. However, I would propose that if the value is quoted when using the CLI, it should be treated as a string and not an integer.
Reacted by Elouan Keryell-Even, Julien, VC, rockydd, Randy Mikkelsaar, Stuart Axelbrooke and rdong8
changed the title [-]Helm converts intigers to scientific notation even when quoted[/-][+]Helm converts integers to scientific notation even when quoted[/+]on Oct 4, 2017
Sorry to necro this thread, but here's a small Helm function to handle the edge-cases:
{{/*
Because of Helm bug (https://github.com/helm/helm/issues/3001), Helm converts
int value to float64 implictly, like 2748336 becomes 2.748336e+06.
This breaks the output even when using quote to render.
Use this function when you want to get the string value only.
It handles the case when the value is string itself as well.
Parameters: is string/number
*/}}
{{- define "stringOrNumber" -}}
{{- if kindIs "string" . }}
{{- print . -}}
{{- else }}
{{- int64 . | toString -}}
{{- end -}}
{{- end -}}
Simply use it in your template yamls like so:
app.kubernetes.io/version: {{ include "stringOrNumber" .Values.global.version | quote }}
^ handles both these cases:
global.version = 2748336
global.version = "2748336"
Activity
[-]Helm converts intigers to scientific notation even when quoted[/-][+]Helm converts integers to scientific notation even when quoted[/+]bacongobbler commentedon Oct 4, 2017
closing as a duplicate of #1707.
jesselang commentedon Feb 13, 2018
Related to #3155
avoid using sha without prefix as a tag
avoid using sha without prefix as a tag
chore(ci): prefix images pushed to GAR with `sha-`. (#11509)
shivanshs9 commentedon Mar 1, 2025
Sorry to necro this thread, but here's a small Helm function to handle the edge-cases:
Simply use it in your template yamls like so:
^ handles both these cases:
global.version = 2748336
global.version = "2748336"
avoid using sha without prefix as a tag