Skip to content

ServiceMonitor template produces invalid YAML due to indent vs nindent in azure-resourcemanager-exporter #108

@ofirwin

Description

@ofirwin

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

  1. Set prometheus.monitor.enabled: true in values
  2. Run helm template .
  3. Observe YAML parse error on the ServiceMonitor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions