Skip to content

Helm: nil pointer evaluating interface {} – wrong context

Helmtested on Helm v4.3.2

The template wants to read a field, but the level above it is already empty. The name after "interface {}." is the field Helm can no longer reach. The message names file, line and column – for a building block from _helpers.tpl also the spot in the helper.

Symptom

helm template notes ./notes -s templates/spielwiese.yaml
Error: notes/templates/spielwiese.yaml:4:11
  executing "notes/templates/spielwiese.yaml" at <include "notes.fullname" .Values>:
    error calling include:
notes/templates/_helpers.tpl:10:14
  executing "notes.fullname" at <.Values.fullnameOverride>:
    nil pointer evaluating interface {}.fullnameOverride

A rendering error: it already shows up with helm template, without a cluster.

Diagnosis

Read the chain from the bottom up. The last line names the field, above it are the expression and the spot in the helper, at the top the call in the template. With -s Helm renders only that one file.

helm template notes ./notes -s templates/spielwiese.yaml
notes/templates/_helpers.tpl:10:14
  executing "notes.fullname" at <.Values.fullnameOverride>:
    nil pointer evaluating interface {}.fullnameOverride

Causes

include … .ValuesWrong context for include

The building block expects the root ".", but gets .Values. It then looks for .Values.fullnameOverride in .Values – that is .Values.Values.fullnameOverride.

sed -i 's/fullname" }}/fullname" .Values }}/' notes/templates/spielwiese.yaml

Subchart offValues of a disabled subchart

If the subchart is disabled, its values disappear completely – including .Values.postgres.auth. The access to .username hits nothing.

direkt: {{ .Values.postgres.auth.username | quote }}
helm template t ./notes --set apiKey.existingSecret=x -s templates/spielwiese.yaml \
  2>&1 | grep nil
    nil pointer evaluating interface {}.username

empty lookupField chain on an empty lookup

With helm template, lookup returns an empty map. A direct field access would break; dig with a default doesn't.

uid: {{ dig "metadata" "uid" "leer" (lookup "v1" "Namespace" "" "kube-system") }}

Fix

Pass the root to building blocks (include "notes.fullname" .). Only use values from subcharts when the subchart is enabled, and use dig with a default for lookup.
B='--set apiKey.existingSecret=x --set global.dbSecret=s --set postgres.enabled=true'
helm template t ./notes $B -s templates/spielwiese.yaml | sed -n '/^data/,$p'
data:
  importiert: "notes"
  direkt: "notes"
▶
Break it yourself and find it – free
Helm Charts hands-on, day 6: building blocks with define, include and _helpers.tpl – context, scope and name collisions.
Go to day 6 →

FAQ

What is the difference to "can't evaluate field Release in type interface {}"?

Inside range the dot is the current element, a string for example. It has no .Release – $ always points to the root there.

And "wrong number of args for include: want 2 got 1"?

include was called without any context. It then refuses right away instead of running the building block.

Related error patterns

More