Skip to content

appVersion unmarshalling error, detected as a floating point #6849

Closed

Description

@vicentfg

If I try to use helm v3 release candidate with existing repositories on our organization, the helm repo add command fails. I was able to replicate it with this simple example:

index.yaml

apiVersion: v1
entries:
  test-chart:
  - apiVersion: v1
    appVersion:  72551e2
    created: 2019-05-06T14:27:00.396Z
    description: Test description
    digest:
    name: test-chart-example
    urls:
    - https://example.com/test-example-0.0.1-0.tgz
    version: 0.0.1-0
generated: "2019-10-31T14:14:13.186531513+02:00"
$ helm3 repo add test-local-repo http://localhost:8000
Error: looks like "http://localhost:8000" is not a valid chart repository or cannot be reached: error unmarshaling JSON: while decoding JSON: json: cannot unmarshal number into Go struct field ChartVersion.entries.appVersion of type string

It seems that yaml parser detects the appVersion as a floating point. This worked correctly with helm version v3.0.0-beta.5, but fails with v3.0.0-rc.1

Output of helm version:

$ helm3 version
version.BuildInfo{Version:"v3.0.0-rc.1", GitCommit:"ee77ae3d40fd599445ebd99b8fc04e2c86ca366c", GitTreeState:"clean", GoVersion:"go1.13.3"}

Activity

  1. bacongobbler commented on Oct 31, 2019

    @bacongobbler
    Member

    72551e2 is scientific notation. Looks like a freaky edge case. Thanks for identifying the issue!

    If you wrap the appversion field in double quotes, does the parser work as expected?

  2. added
    bug
    v3.x
    on Oct 31, 2019
  3. kopwei commented on Nov 4, 2019

    @kopwei

    72551e2 is scientific notation. Looks like a freaky edge case. Thanks for identifying the issue!

    If you wrap the appversion field in double quotes, does the parser work as expected?

    Wrapping "72551e2" with quote fix the issue temporarily. It seems it is brought in by #6808 .

  4. kopwei commented on Nov 4, 2019

    @kopwei

    Since git hash is widely used in versioning, many existing chart repo will not work after upgrade to helmv3

  5. karuppiah7890 commented on Nov 4, 2019

    @karuppiah7890
    Contributor

    I'm thinking anything that creates or serves index.yaml should put double quotes on anything that's a string. That just solves the problem entirely. What do you folks think? I can't think of any other clean way of fixing this

    This fix would require helm repo index to create yamls with double quotes around strings, and changes in https://github.com/helm/chartmuseum too may be, as people use that too

  6. bacongobbler commented on Nov 4, 2019

    @bacongobbler
    Member

    re-labeling as a bug for Helm 2, as this has to do with how helm repo index generates the index fields. The YAML parser in Helm 3 is parsing the string correctly as scientific notation.

  7. added
    v2.x
    and removed
    v3.x
    on Nov 4, 2019
  8. karuppiah7890 commented on Nov 4, 2019

    @karuppiah7890
    Contributor

    I'll see what I can do with regards to this. Will raise a PR once I find out how this can be fixed

  9. kopwei commented on Nov 4, 2019

    @kopwei

    re-labeling as a bug for Helm 2, as this has to do with how helm repo index generates the index fields. The YAML parser in Helm 3 is parsing the string correctly as scientific notation.

    But for version field, how likely people would put a scientific value there? If it is not considered to be fixed in 3.x, which means all existing index.yaml in chart repo has to be re-generated for helm v3 client binary.

  10. karuppiah7890 commented on Nov 4, 2019

    @karuppiah7890
    Contributor

    @kopwei I'll check if helm 3 also creates repo index like this. In any case, it's not the client's fault. And however, we can't look at the likeliness/probability of people having scientific like notations. I also had a similar issue in our codebase today, and realized it's the same issue as this. 😅

    Also, index has to be recreated anyway when repositories are updated with new versions of charts. So, I wouldn't consider that as a problem. I would just consider it as a small fix for users, if they are facing this issue. Fix would be update helm and recreate index

  11. kopwei commented on Nov 4, 2019

    @kopwei

    @karuppiah7890 , normally a helm binary user is not the maintainer of chart repo, which means we need to push the chart repo maintainer to upgrade the helm binary in continuous integration tool to latest v2 in order to re-generate the charts until we can use the helmv3 client binary. Or. the workaround I can think of is to run "helm repo add" command with helm-v3.0.0-beta5 and then switch to helm v3 release to perform the rest installation job.

  12. bacongobbler commented on Nov 4, 2019

    @bacongobbler
    Member

    But for version field, how likely people would put a scientific value there?

    It doesn't matter whether or not the use case is valid for the application. The point is that the YAML parser used in Helm fixed a bug to match the YAML specification on scientific notation. A field with a value of 72551e2 is considered a number as per the YAML spec, and the parser is now correctly treating it as such.

    The bug is that the code to serialize the index in YAML is not quoting the appversion field to a string type correctly. Had it been handling that correctly before, this would not be an issue.

  13. added
    v3.x
    on Nov 4, 2019
  14. bacongobbler commented on Nov 4, 2019

    @bacongobbler
    Member

    Good call about checking helm repo index for Helm 3, @karuppiah7890. I forgot that it still existed.

  15. karuppiah7890 commented on Nov 16, 2019

    @karuppiah7890
    Contributor

    This can be closed as the latest version of v2 (2.16.1) and v3 (3.0.0) both create repository index with double quotes around appVersion when Chart.yaml has content like this appVersion: 72225e2.

    But it gets converted to appVersion: "7.2225e+06" in the packaged chart and the same comes in the repository index. There are different issues for explaining and discussing that #6921 (v3) and #6922 (v2, closed)

  16. karuppiah7890 commented on Nov 16, 2019

    @karuppiah7890
    Contributor
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

    bugv2.xv3.x

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions