helm: cannot unmarshal string into Go value of type releaseutil.SimpleHead
I am getting unmarshal error on simple validation that I am performing from my .tpl file.
I have a function defined in _helpers.tpl like:-
{{- define "actionValidate" -}}
{{ $action := .Values.actions }}
{{- if or (eq $action "action1") (eq $action "action2") (eq $action "action3") -}}
true
{{- end -}}
{{- end -}}
I 'm invoking this function from one of the .tpl file inside templates folder .
{{ include "actionValidate" . | required "Action value is incorrect. The valid values are 'action1', 'action2', 'action3' " }}
On running helm install command , I’m getting following issue:- ‘error unmarshaling JSON: json: cannot unmarshal string into Go value of type releaseutil.SimpleHead’
However helm dry run command does not show any error and is executed successfully.
Output of helm version
:
Client: &version.Version{SemVer:“v2.13.1”, GitCommit:“618447cbf203d147601b4b9bd7f8c37a5d39fbb4”, GitTreeState:“clean”}
Server: &version.Version{SemVer:“v2.13.1”, GitCommit:“618447cbf203d147601b4b9bd7f8c37a5d39fbb4”, GitTreeState:“clean”}
Output of kubectl version
:
Client Version: version.Info{Major:“1”, Minor:“14”, GitVersion:“v1.14.0”, GitCommit:“641856db18352033a0d96dbc99153fa3b27298e5”, GitTreeState:“clean”, BuildDate:“2019-03-25T15:53:57Z”, GoVersion:“go1.12.1”, Compiler:“gc”, Platform:“linux/amd64”}
Server Version: version.Info{Major:“1”, Minor:“14”, GitVersion:“v1.14.0”, GitCommit:“641856db18352033a0d96dbc99153fa3b27298e5”, GitTreeState:“clean”, BuildDate:“2019-03-25T15:45:25Z”, GoVersion:“go1.12.1”, Compiler:“gc”, Platform:“linux/amd64”}
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 10
- Comments: 27 (6 by maintainers)
Same issue in my case with that:
results in
Does anyone know a workaround for this or an alternative to achieve the same thing I am trying to do? I am not familiar with Helm Charts and the Helm Documentation is absolutely atrocious and disgusting. I would appreciate any help leading me in the right direction.
@Saurabh-16 Looking at this again I am finding an issue during install when I use required. Output from my investigation as follows.
Looks like this might be a bug.
Is this an issue or there is something wrong with the code syntax .
For other travelers who find themselves here… This can also be caused by certain unprintable chars/bytes making their way into your YAML, say when going through certain editors. YMMV.
Another easy solution is to just do
{{ $_ := ... }}
However the error reporting for this failure is still a PITA.
For me, it’s about wrong filename of Notes… Instead of
NOTES.txt
, it wasNotes.txt
It’s working now after renaming itmv templates/Notes.txt templates.NOTES.txt
i have the same problem Or am I using the wrong method?
1.toml
helm version
template
when modified to json
template as follows
thanks
I’ve added a PR but the auto linking hasn’t worked.
I’ll re-open this as an open invitation for someone to look into this issue. I don’t have enough time to fix this but contributions are welcome. Thanks for the reproduction case @caleb15.
I’m getting this error with helm version 3.5.0.
Replication steps:
helm create foo2
required
line from https://helm.sh/docs/howto/charts_tips_and_tricks/ at the start of the deployment yaml file with---
on the second line:sed -i '1s/^/\{\{ required "A valid .Values.who entry required!" .Values.who \}\}\n---\n/' foo2/templates/deployment.yaml
who: bob
at the end of the values file:echo "who: bob" >> foo2/values.yaml
helm template foo2
@hickeyma can you remove the stale lifecycle please? It might be more than 30 days between reports but this is a persistent issue and is now easily replicable.
+1 same issue with Helm v3.2.1
same here.when I try to create a configmap from files.