Description
The ServiceMonitor template in the azure-resourcemanager-exporter chart produces invalid YAML when prometheus.monitor.enabled is set to true.
Root Cause
In templates/prometheus/servicemonitor.yaml, line 8:
labels: {{ include "azure-resourcemanager-exporter.labels" . | indent 4 }}
This uses indent 4 instead of nindent 4. Since indent does not prepend a newline, the labels output is placed on the same line as labels:, producing:
labels: helm.sh/chart: azure-resourcemanager-exporter-1.3.6
This is invalid YAML — helm.sh/chart: is interpreted as a nested mapping key within the labels scalar value, causing:
Error: YAML parse error on azure-resourcemanager-exporter/templates/prometheus/servicemonitor.yaml:
error converting YAML to JSON: yaml: line 6: mapping values are not allowed in this context
Affected Versions
All versions from 1.0.0 through 1.3.6 (latest). The bug has never been caught because prometheus.monitor.enabled defaults to false.
Fix
Change indent to nindent on line 8 of templates/prometheus/servicemonitor.yaml:
- labels: {{ include "azure-resourcemanager-exporter.labels" . | indent 4 }}
+ labels:
+ {{- include "azure-resourcemanager-exporter.labels" . | nindent 4 }}
Steps to Reproduce
- Set
prometheus.monitor.enabled: true in values
- Run
helm template .
- Observe YAML parse error on the ServiceMonitor
Description
The ServiceMonitor template in the
azure-resourcemanager-exporterchart produces invalid YAML whenprometheus.monitor.enabledis set totrue.Root Cause
In
templates/prometheus/servicemonitor.yaml, line 8:This uses
indent 4instead ofnindent 4. Sinceindentdoes not prepend a newline, the labels output is placed on the same line aslabels:, producing:This is invalid YAML —
helm.sh/chart:is interpreted as a nested mapping key within thelabelsscalar value, causing:Affected Versions
All versions from 1.0.0 through 1.3.6 (latest). The bug has never been caught because
prometheus.monitor.enableddefaults tofalse.Fix
Change
indenttonindenton line 8 oftemplates/prometheus/servicemonitor.yaml:Steps to Reproduce
prometheus.monitor.enabled: truein valueshelm template .