Skip to content

Setting large int64 values in values.yaml converts them to float64 #11130

Closed

Description

@schnerring

I've already mentioned this here but since the issue is closed I thought it was a good idea to open a new issue.

Output of helm version:

version.BuildInfo{Version:"v3.8.2", GitCommit:"6e3701edea09e5d55a8ca2aae03a68917630e91b", GitTreeState:"clean", GoVersion:"go1.17.5"}

To reproduce the issue, create the following template.

helm create foo

cd foo

cat << EOF > templates/foo.yaml
value: {{ .Values.foo }}
type: {{ typeOf .Values.foo }}
EOF

Using --set, everything works as expected:

$ helm template foo . --set foo=10485760 --show-only templates/foo.yaml
---
# Source: foo/templates/foo.yaml
value: 10485760
type: int64

However, setting the value in values.yaml:

foo: 10485760

... changes the behavior:

$ helm template foo . --show-only templates/foo.yaml
---
# Source: foo/templates/foo.yaml
value: 1.048576e+07
type: float64

A workaround is multiplying the value with 1 in the template:

value: {{ mul .Values.foo 1 }}

This changes the rendered output to the following (note the type still is float64):

---
# Source: foo/templates/foo.yaml
value: 10485760
type: float64

Activity

  1. bacongobbler commented on Jul 9, 2022

    @bacongobbler
    Member

    related: #11045

  2. added
    bug
    on Jul 10, 2022
  3. github-actions commented on Oct 9, 2022

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  4. dmekhov commented on Oct 10, 2022

    @dmekhov

    it's still actual

  5. ryanotella commented on Oct 21, 2022

    @ryanotella

    This is still an issue, but there are work-arounds for template authors who cannot guarantee the quoting semantics of input YAML. For string values which are sometimes integers, it seems it's necessary to avoid that standard Go template string casting - using toJson or toYaml is one option.

    For values with are always integers:

    {{ .Values.alwaysInteger | int64 | quote }}
    

    For values which are sometimes integers (Hashes, IDs etc):

    {{ .Values.sometimesInteger | toJson | trimAll "\"" | quote }}
    

    Test

    values.yaml

    samples:
      alwaysIntegerBare: 325255969
      alwaysIntegerQuoted: "325255969"
      sometimesIntegerBare: 325a255969
      sometimesIntegerQuoted: "325a255969"
    

    template.yaml

    # int64 | quote
    # {{ .Values.samples.alwaysIntegerBare | int64 | quote }}
    # {{ .Values.samples.alwaysIntegerQuoted | int64 | quote }}
    # {{ .Values.samples.sometimesIntegerBare | int64 | quote }}
    # {{ .Values.samples.sometimesIntegerQuoted | int64 | quote }}
    
    # toJson | trimAll "\"" | quote
    # {{ .Values.samples.alwaysIntegerBare | toJson | trimAll "\"" | quote }}
    # {{ .Values.samples.alwaysIntegerQuoted | toJson | trimAll "\"" | quote }}
    # {{ .Values.samples.sometimesIntegerBare | toJson | trimAll "\"" | quote }}
    # {{ .Values.samples.sometimesIntegerQuoted | toJson | trimAll "\"" | quote }}
    

    Output

    # int64 | quote
    # "325255969"
    # "325255969"
    # "0"
    # "0"
    
    # toJson | trimAll "\"" | quote
    # "325255969"
    # "325255969"
    # "325a255969"
    # "325a255969"
    
  6. added
    help wanted
    on Oct 22, 2022
  7. github-actions commented on Jan 20, 2023

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  8. schnerring commented on Jan 20, 2023

    @schnerring
    Author

    unstale

  9. joejulian commented on Jan 27, 2023

    @joejulian
    Contributor

    To everyone who finds this issue, not just the OP:

    This is a duplicate of #9362. As stated in that issue, it's a problem that stems from kubernetes-sigs/yaml#45. Also as stated, changing this in helm would require a Helm Improvement Proposal because it's not as straightforward as replacing the yaml library. Give the original issue a look and consider helping write up a HIP. The yaml landscape in go has changed since then, though I don't know if compatibility has gotten any better overall.

    Also, feel free to give feedback on the upstream issue, or contribute a fix if you're able.

  10. github-actions commented on Apr 28, 2023

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  11. homm commented on Jul 24, 2025

    @homm

    Completed? How convenient 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stalebughelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions