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
I just noticed that something like helm install --set tag=20161216 ends up in scientific notation in the template and thats because {{ typeOf .Value.tag }} yields float64.
Thats even true for small integers like helm install --set tag=1 --> float64.
This is happening with helm 2.1.0
Reacted by Ravi Mehra, Vitalii Zakharov, Joe Eli McIlvain, eduardo aleixo, David Currie, Joseph Crotty, Benjamin Jordan, Martin Stiborský, Mike Kantzer, Philippe Dupont and 76 more
Thanks to @chancez we know the exact problem: During the conversions to and from JSON done by ghodss/yaml, integers are being cast into float64s to represent Javascript's numeric type. This is causing all integers above a certain value to be represented in scientific notation.
Reacted by Jan Willies, Ricardo Castro, notque, John Evans and Thomas Nordengen
I've been bitten by the same problem. The way of getting over the hump (or the bug) is to do this:
--set bignumber=\\"a185576882739235744\\"
Reacted by Michaël Rivet, Sasha (Alejandro Vicente Grabovetsky), BedivereZero, Jesher Heliel Rodrigues, Mathieu, Ludovic Annette, Amin, Pawan Kumar, Jeremy Johnson and Brian D
Reacted by Alessandro Diaferia, Bruno Manzo, Patrick Lee Scott, cr-kobyisrael, Jason Kolios, Eoghan, Dan Hipschman, AJ Jwair, Ewen, Amaury Gauthier and 48 more
Reacted by Jaikanth S, Anthony Vickers, Carlos González, Loïc Gombeaud and jbrardport
Also, within my own specific issue, I was using %d to indiciate that I have a number value, I want to put that into the string format, but it would print as %!d(float64=1433) rather than putting 1433 into that position.
Using this does not work, because as soon as the tag changes to something that isn't an int, we have a helm problem.
image: "{{ .Values.sidecar.image.repository }}:{{ .Values.image.tag | int }}"
Reacted by Antonio Soldo, Marcus Wyremblewski, JonParsons11350, Bernhard Posselt, Marco Paggioro, ayasinn, Bret Rickerson, Dingkang Li and Ondrej Zizka
Reacted by Malte Hviid-Magnussen, Nelo-T. Wallus, Romain Dartigues, Ryan Campbell, Guowen Huang, Matt Sturdy, Ivan Ka, rdong8, MD Islam, Ben Stanley and 7 more
Reacted by Thiago Moura, Ryan Campbell and Vinicius Vassão
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"
Basically, if the issue is that Helm implicitly interprets number as float64 type, then it should be solved if I explicitly mark it as int64. Once that's done, it's pretty easy to make it a string and pass around.
Reacted by Andrew Mickael, Paul K., Vinicius Vassão, Samuel López Iglesias and immuslim
Activity
[-]--set [/-][+]--set parses big ints as float64[/+][-]--set parses big ints as float64[/-][+]--set parses number only values as float64[/+]technosophos commentedon Dec 19, 2016
Does it work differently if you do
--set tag=\"1\"?technosophos commentedon Dec 20, 2016
Thanks to @chancez we know the exact problem: During the conversions to and from JSON done by
ghodss/yaml, integers are being cast into float64s to represent Javascript's numeric type. This is causing all integers above a certain value to be represented in scientific notation.ipedrazas commentedon Jan 5, 2017
I've been bitten by the same problem. The way of getting over the hump (or the bug) is to do this:
--set bignumber=\\"a185576882739235744\\"technosophos commentedon Feb 15, 2017
Another workaround we have used is to do stuff like this:
Then in the template:
databus23 commentedon Feb 15, 2017
Yuck! 😷
Attempt to use escaping option values to work around helm/helm#1707
Second attempt to use escaping option values to work around helm/helm…
3 - Attempt to use escaping option values to work around helm/helm#1707
jemc commentedon Aug 14, 2017
This is a heck of a pain, and @ipedrazas' workaround doesn't seem to work for me, or any other combination of quoting/escaping I've tried.
I'm not quite willing yet to swallow my pride and try @technosophos' ugly hack...
For now I'm hacking around this by expanding my deploy script to write the data as yaml to a temporary file and use that as a
-fargument.Smana commentedon Aug 31, 2017
I'm facing the same issue from time to time for the image tag.
I'll try to use one of these workaround. I hope it will be fixed soon :)
Prevent string to numeric
holybit commentedon Oct 5, 2017
In my case, seeing this below on
--set image.tag=5997578:116 remaining items
Mo0rBy commentedon Dec 14, 2023
Also, within my own specific issue, I was using
%dto indiciate that I have a number value, I want to put that into the string format, but it would print as%!d(float64=1433)rather than putting1433into that position.nikicat commentedon Dec 14, 2023
I suppose this thread is about the command line argument parser, not the YAML parser.
Mo0rBy commentedon Dec 14, 2023
Ah right sorry, I misinterpreted what you meant
dberardo-com commentedon Mar 15, 2024
after reading through all this discussion i am stil confused ... is there any workaround so far ? like using "| quote" ? or what ?
sebastianpiskorski commentedon Apr 25, 2024
| quotedoesn't workMalteMagnussen commentedon Apr 30, 2024
Vote for reopening. Just saw this as well.
deployment.yaml:with
values.yaml:becomes desired manifest of:
Using this does not work, because as soon as the tag changes to something that isn't an int, we have a helm problem.
aoledk commentedon Aug 20, 2024
You can quote image.tag with
""to resolve this problem.rehevkor5 commentedon Oct 11, 2024
The workaround appears to be to use
--set-stringinstead of--set, added by #3599bcdurden commentedon Nov 17, 2024
How is this still a problem over 7 years later?
alimnette commentedon Dec 3, 2024
thank you, work for me :)
fix: work around for helm/helm#1707
fix: work around for helm/helm#1707
chore(deps): upgrade to version 0.4.3
chore(deps): upgrade to version 0.4.4
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"
Basically, if the issue is that Helm implicitly interprets number as float64 type, then it should be solved if I explicitly mark it as int64. Once that's done, it's pretty easy to make it a string and pass around.