Unable to render templates for job otel-collector with undefined method '[]' for nil
search cancel

Unable to render templates for job otel-collector with undefined method '[]' for nil

book

Article ID: 448795

calendar_today

Updated On:

Products

VMware Tanzu Platform - Cloud Foundry

Issue/Introduction

Applying changes in OpsManager fails when portions of the OpenTelemetry (otel) collector configuration are commented out or left intentionally blank. The deployment fails and generates the following error messages across affected VM types:

Task 2104063 | 12:22:22 | Preparing deployment: Rendering templates (00:00:12)
                        L Error: Unable to render instance groups for deployment. Errors are:
  - Unable to render jobs for instance group 'nats'. Errors are:
    - Unable to render templates for job 'otel-collector'. Errors are:
      - Error filling in template 'config.yml.erb' (line 299: undefined method `[]' for nil)

Note: The error above is for nats, but could be any VM type. 


This error typically occurs when testing configuration changes or isolating errors by commenting out large configuration blocks (such as processors, exporters, or extensions) in the OpenTelemetry Collector Configuration text box.

Environment

 

  • Elastic Application Runtime (EAR) up to 10.4.2, 10.3.8 and 10.2.12

 

Cause

The config.yml.erb template fails to handle missing or null keys gracefully.

In standard OpenTelemetry configurations, leaving a key empty (evaluating to null) normally implies default settings. However, the internal template enforces stricter validation and expects specific data types. When configuration keys are present but contain no values—or when the text box contains only comments and whitespace alongside empty keys—the YAML parser evaluates those keys as nil. The internal Ruby template attempts to access these missing values using the [] method, resulting in the undefined method error.

An entirely empty configuration box evaluates as an empty string and processes without error. However, a configuration containing non-empty YAML (even if it only consists of comments) triggers the strict parsing limitations.

Resolution

In 10.4.3+, 10.3.9+ and 10.2.13+, OTEL erb handling will be more robust, ensuring it correctly manages cases where the property value is empty or contains only comments.

To bypass this issue immediately, implement one of the following workarounds:

Workaround 1: Clear the Configuration Box

Remove all text, including comments, keys, and whitespace, from the OpenTelemetry Collector Configuration text box. An entirely empty string parses successfully.

Workaround 2: Provide Explicit Empty Data Types

When maintaining comments or partial configurations, explicitly define the mandatory keys with expected empty data types (such as empty maps {} or empty arrays []) instead of leaving them implicitly blank.

Format the base configuration keys to satisfy the strict parser requirements:

YAML
# processors: {}

# exporters: {}

extensions: {}

service:
  extensions: []
  pipelines: {}

Ensure no base keys are left trailing with a colon but without a designated empty value.

 

Additional Information

The OpsManager error message does not explicitly name the configuration key responsible for the failure. Identifying the exact missing key requires unpacking the EAR tile, navigating to releases/tanzu-otel-collector-####/jobs/otel-collector/templates/config.yml.erb, and matching the line number from the error output to the corresponding section (e.g., processors, exporters, extensions, or pipelines) in the .erb file.

The error message will be also improved in future releases.