Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot unmarshal number into Go struct field ChartVersion.appVersion of type string #368

Closed
juliendangers opened this issue Oct 29, 2019 · 6 comments

Comments

@juliendangers
Copy link

juliendangers commented Oct 29, 2019

Terraform Version

Terraform v0.12.12

  • provider.helm v0.10.4

Affected Resource(s)

  • helm_repository

Terraform Configuration Files

data "helm_repository" "keda" {
  name = "keda"
  url  = "https://kedacore.azureedge.net/helm"
}

Debug Output

Error: Looks like "https://kedacore.azureedge.net/helm" 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.appVersion of type string

It worked perfectly in previous versions (<= 0.12), but since appVersion is commit hash in keda repo, if you added number type restriction, it cannot work. The repository is valid => https://kedacore.azureedge.net/helm/index.yaml

Expected Behavior

Since the spec does not provide type information, we should not expect it to be a number. I've seen many things like vx.x.x

Actual Behavior

Crash while attempting to convert a string into a number

Steps to Reproduce

  1. terraform plan
@Carles-Figuerola
Copy link

Carles-Figuerola commented Oct 30, 2019

We are finding the same problem since the release of 0.10.3. We are wondering if the parsing of the file is being done differently because of this upgrade: 107d7de

One theory in our case is when a version string happens to look like 319e199, which might be parsed as an integer instead of a string, which causes a type mismatch down the code.

@rehevkor5
Copy link

Yes, but I think you meant that it's getting parsed as float. I believe this is also related to go-yaml/yaml#290 which fixed gopkg.in/yaml.v2 to resolve tags in a way which more accurately matches the YAML 1.2 spec. Specifically, that the [-+] is optional in floats.

Specifically, the error we were getting was:

Looks like "https://ourrepo.example.com/foo/" 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.version of type string

The problematic version in question is coming from the https://ourrepo.example.com/foo/index.yaml file that Helm provider is downloading.

We happen to be using Artifactory as our repo provider, and it looks like there is an existing bug about this issue: https://www.jfrog.com/jira/browse/RTFACT-20334 However, it might be good to have a workaround on the Helm Provider side as well.

@rehevkor5
Copy link

Also, I don't know exactly where this should be done, but ideally the YAML->JSON code would be able to produce a more informative error message, or there could be a setting for increased logging verbosity. As it stands, the output does not provide enough information to identify which specific value or line caused the problem.

@zodrog
Copy link

zodrog commented Nov 6, 2019

Same exact problem here with kedacore.

As a workaround I had to downgrade to version 0.9.1

provider "helm" {

kubernetes {
host = "${module.kubernetes.host}"

client_certificate              = "${base64decode(module.kubernetes.client_certificate)}"
client_key                      = "${base64decode(module.kubernetes.client_key)}"
cluster_ca_certificate          = "${base64decode(module.kubernetes.cluster_ca_certificate)}"

}

install_tiller = "true"
service_account = "tiller"
tiller_image = "gcr.io/kubernetes-helm/tiller:v2.13.0"
namespace = "kube-system"
version = "0.9.1"

}

Cheers

@mcuadros
Copy link
Collaborator

Closing this issue since is making reference to a version based on Helm 2, if this is still valid to the master branch please reopen it. Thanks.

@ghost
Copy link

ghost commented May 11, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators May 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants