Skip to content

fix: remove tpl function causing template rendering error#2037

Open
jerry-shao wants to merge 2 commits intoopen-telemetry:mainfrom
jerry-shao:fix-template-tpl-issue
Open

fix: remove tpl function causing template rendering error#2037
jerry-shao wants to merge 2 commits intoopen-telemetry:mainfrom
jerry-shao:fix-template-tpl-issue

Conversation

@jerry-shao
Copy link

Description

Fix template rendering error in OpenTelemetry Demo chart caused by tpl function compatibility issues with newer Helm versions.

Problem

The chart was failing to deploy with the following error:

➜  ~ helm install my-otel-demo open-telemetry/opentelemetry-demo

Error: INSTALLATION FAILED: template: opentelemetry-demo/templates/component.yaml:12:12: executing "opentelemetry-demo/templates/component.yaml" at <include "otel-demo.deployment" $config>: error calling include: template: opentelemetry-demo/templates/_objects.tpl:109:16: executing "otel-demo.deployment" at <include "otel-demo.pod.env" .>: error calling include: template: opentelemetry-demo/templates/_pod.tpl:43:4: executing "otel-demo.pod.env" at <tpl (toYaml $allEnvs) .>: error calling tpl: cannot retrieve Template.Basepath from values inside tpl function: - name: OTEL_SERVICE_NAME
  valueFrom:
    fieldRef:
      apiVersion: v1
      fieldPath: metadata.labels['app.kubernetes.io/component']
- name: OTEL_COLLECTOR_NAME
  value: otel-collector
- name: OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE
  value: cumulative
- name: FLAGD_METRICS_EXPORTER
  value: otel
- name: OTEL_EXPORTER_OTLP_ENDPOINT
  value: http://$(OTEL_COLLECTOR_NAME):4318
- name: FLAGD_UI_PORT
  value: "4000"
- name: SECRET_KEY_BASE
  value: yYrECL4qbNwleYInGJYvVnSkwJuSQJ4ijPTx5tirGUXrbznFIBFVJdPl5t6O9ASw
- name: PHX_HOST
  value: localhost
- name: OTEL_RESOURCE_ATTRIBUTES
  value: service.name=$(OTEL_SERVICE_NAME),service.namespace=opentelemetry-demo,service.version={{
    .Chart.AppVersion }}: "BasePath" is not a value

Root Cause

The tpl function in _pod.tpl was attempting to re-process already-rendered YAML content as a template, which triggered Helm's restriction on accessing Template.Basepath within tpl functions in newer versions.

Solution

Replaced {{- tpl (toYaml $allEnvs) . }} with {{- toYaml $allEnvs }} in the pod environment template helper.

Changes

  • File: charts/opentelemetry-demo/templates/_pod.tpl
  • Change: Remove unnecessary tpl wrapper around toYaml output
  • Impact: Maintains identical functionality while fixing Helm compatibility

Testing

  • Chart deploys successfully with local changes
  • All demo services accessible via frontend proxy
  • No regression in generated YAML output

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
The tpl function in _pod.tpl was causing template rendering failures
with newer Helm versions due to inability to access Template.Basepath.
Replaced with direct toYaml output which achieves the same result.
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 18, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: jerry-shao / name: Mingjie Shao (a87d1f7)

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2026

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Feb 2, 2026
{{- end }}

{{- tpl (toYaml $allEnvs) . }}
{{- toYaml $allEnvs }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm no sure removing the tpl call is the way we want to solve this as it'll remove the ability to define env vars with a template. I dont believe tpl is called anywhere higher in this function. What version of helm are you running?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problematic version:

> helm version
version.BuildInfo{Version:"v3.13.2", GitCommit:"2a2fb3b98829f1e0be6fb18af2f6599e0f4e8243", GitTreeState:"clean", GoVersion:"go1.21.4"}

Working versions:

> helm version
version.BuildInfo{Version:"v4.1.0", GitCommit:"4553a0a96e5205595079b6757236cc6f969ed1b9", GitTreeState:"clean", GoVersion:"go1.25.6", KubeClientVersion:"v1.35"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you able to point to a breaking change in helm 4 that is causing the chart not to work on 4.1?

Copy link
Member

@TylerHelmuth TylerHelmuth Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, can you confirm the behavior of otel-demo.pod.env with tpl removed? I assume it no longer handles rendering templated env var inputs. That is a feature we need to continue to support

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @TylerHelmuth

helm 3.13.2 is the problematic version, the newer version 4.1.0 doesn't have this problem.

@github-actions github-actions bot removed the Stale label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants