-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Error converting YAML to JSON could not find expected ':' #2004
Comments
That is a peculiar bug. With the problematic JSON, have you run it through a JSON linter just to be sure there isn't some hidden character causing a problem? Otherwise, it sounds like we might have an error in the upstream YAML parser. |
It worked fine in online linters I tried. I thought initially that it was related to BOM, but both files(working and not working) did not have it. I have attached minimal chart that is causing it for me: running
if you add space it seems to produce completely different result
|
@Rurouni Are you still having issues with this? |
I'm having a similar issue. When I have a ConfigMap template defined as follows: apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-{{ .Chart.Name }}-configs
data:
config.properties: |-
{{ .Files.Get "config.properties" | indent 2 }} And,
I receive the following error: However, it works fine if
|
For what it's worth, I found that I no longer get an error with multi-line files if I change my ConfigMap template to the following:
Notice that |
I haven't seen it for a while, so I am closing this |
Happens due to a minor indent (1 instead of two, or two instead of four), in a wrong place. |
Is there a way to have helm output the bad yaml so we can debug? |
☝️ Which has been merged into master and is coming out in 2.7 |
Thank you @ravindranathakila. Indenting data with 4 spaces worked for me (in my case it required 4 spaces)! |
The error message in my case was quite cryptic, it was just complaining about a "line 8" without saying what file to look into. Like this basically: I solved by running The output with the $ helm lint reducers
==> Linting reducers
[INFO] Chart.yaml: icon is recommended
[ERROR] templates/: render error in "reducers/templates/configmap.yaml": template: reducers/templates/configmap.yaml:24:27: executing "reducers/templates/configmap.yaml" at <.Values.global.kafka...>: can't evaluate field kafkaUrl in type interface {}
Error: 1 chart(s) linted, 1 chart(s) failed Which of course has nothing to do with any line 8 but it definitely highlighted the right problem 👍 |
I got this error while writing config maps object using Helm . This error had nothing to do with YAML but more with quotations I was getting following
Debugging: I ran helm in debug and dry-run mode to see what was the property file format getting outputted helm install --debug --name my-release-name ./my-superawesome-chart --dry-run Solution: Use quote method in the templates/your-config-map-definition.yaml $ cat templates/your-config-map-definition.yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
name: my-superawesome-app
data:
application.properties: {{ .Files.Get "application.properties" | quote }} |
this seems to work , but how do i make application.properties per environment ? example dev has different contents , qa has different and prod has different |
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
|
It happen when i didn't add The error appeared when it was : kind: CronJob
metadata:
name: scheduler-{{ include "laravel.fullname" . }}
labels:
{{- include "laravel.labels" . | nindent 4 }}
spec:
schedule: "{{ .Values.scheduler.schedule }}"
jobTemplate:
spec:
template:
spec:
# containers: ... And the error disappears when it is : kind: CronJob
metadata:
name: scheduler-{{ include "laravel.fullname" . }}
labels:
{{- include "laravel.labels" . | nindent 4 }}
spec:
schedule: "{{ .Values.scheduler.schedule }}"
jobTemplate:
metadata:
labels:
{{- include "laravel.labels" . | nindent 8 }}
spec:
template:
metadata:
labels:
{{- include "laravel.labels" . | nindent 12 }}
spec:
# containers: ... |
I don't know whether this helps test.json {
"asdfasdfasdf": "asd"
} This return apiVersion: v1
kind: ConfigMap
metadata:
name: profile
data:
token: |-
{{ .Files.Get "files/test.json" }} This return same error apiVersion: v1
kind: ConfigMap
metadata:
name: profile
data:
token: |-
{{ .Files.Get "files/test.json" | indent 2}} This works apiVersion: v1
kind: ConfigMap
metadata:
name: profile
data:
token: |-
{{ .Files.Get "files/test.json" | indent 4}} |
I had a similar problem with a multiline yaml. multiline yaml:
This returned
Then taking out the quotes, it worked:
|
$ cat templates/config-map.yaml
config_dev.json (same as config_qa.json)
I am having an issue in update the config file using the below command kubectl apply -f helm/templates/config-map.yaml -n $NAMESPACE ** error: error parsing helm/templates/config-map.yaml: error converting YAML to JSON: yaml: line 8: could not find expected ':' ** Note: When I do the helm install deployment, it works fine. But my requirement is update the configmap without restarting the pod |
In my case, I had JSON stringified config in Azure Key Vault. So, during deployment in the helm chart step, it gave me the same error As a workaround, I base64 encoded the JSON stringified config and stored in key vault. This worked for me. Hope someone will find this useful. |
This workds as expected if you are passing json content in helm values.yaml |
I have just run into very curious bug with
(.Files.Glob "configOverrides/*").AsConfig
Suddenly one of my services charts started to fail on helm upgrade with obscure
But the weird thing was that other almost identical chart was succeeding.
Both of them have pretty standard
both of them incude appconfig.json file that is valid json and encoded with UTF-8 without BOM
and the only difference in appconfig.json file that I was able to find was one "space" in it.
After some testing: Even having config file as simple as
is failing with error above but as soon as I add space at the end of if
it works fine...
also it works fine if config has no space but
<CRLF>
instead of<LF>
Env: Helm version 2.2 running in ubuntu 16.04 based docker container
The text was updated successfully, but these errors were encountered: