<p>I am building a new Helm chart (<strong>mychart</strong>) that I'm trying to install.</p>
<p>A <code>values.yaml</code> exists and its contents specify the fullnameOverride:</p>
<pre class="lang-yaml prettyprint-override"><code>fullnameOverride: &quot;myapp&quot;
</code></pre>
<p>I run the following command</p>
<p><code>helm install --dry-run -f &quot;mychart-stack/values.yaml&quot; mychart-stack1 ./mychart-stack</code></p>
<p>And it's giving me the error:</p>
<blockquote>
<p>template: mychart-stack/templates/persistentvolume.local-storage.range.yml:5:14: executing &quot;mychart-stack/templates/persistentvolume.local-storage.range.yml&quot; at &lt;include &quot;mychart-stack.fullname&quot; .&gt;: error calling include: template: mychart-stack/templates/_helpers.tpl:14:14: executing &quot;mychart-stack.fullname&quot; at &lt;.Values.fullnameOverride&gt;: nil pointer evaluating interface {}.fullnameOverride</p>
</blockquote>
<p>The <code>mychart-stack/templates/_helpers.tpl:14:14</code> is the pregenerated one when you're asking Helm to produce a Chart example.</p>
<p>The error (14:14) is associated at the first line of the following auto generated code:</p>
<pre class="lang-yaml prettyprint-override"><code>{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix &quot;-&quot; }}
{{- else }}
</code></pre>
<hr />
<p>A little more context, as it's throwing an error while checking the persistentvolume.local-storage.range.yml, here are the contents of the file:</p>
<pre class="lang-yaml prettyprint-override"><code>{{- range .Values.persistentVolume.localStorage }}
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-{{ include &quot;mychart-stack.fullname&quot; }}-{{ .name }}
spec:
  capacity:
    storage: 20Gi
  # le champ volumeMode requiert l'activation de la &quot;feature gate&quot; Alpha BlockVolume
  volumeMode: Filesystem
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  storageClassName: local-storage-{{ include &quot;mychart-stack.fullname&quot; }}--{{ .name }}
  local:
    path: {{ .Values.persistentVolume.basePath }}/{{ .name }}
  nodeAffinity:
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: kubernetes.io/hostname
          operator: In
          values:
          - {{ .Values.hostName }}
{{- end }}
</code></pre>
<p>I don't know what's wrong, the code seems to indicate that it's not defined properly.
I tried to run it in --debug mode but it doesn't help (same error).</p>

<p>Finally the problem wasn't the values.yaml that was not set correctly but more the way it was used within the template.</p>
<p>When using an include of a definition coming from a .tpl file (this one was the autogenerated by Helm), we must be careful to not be in a range.</p>
<p>I was creating a range of assets so it seems that it will run the code in the context of the range.</p>
<blockquote>
<p>Your conditional logic is being evaluated inside a range loop. This means . you're using to access Values is not the one you expect it to be, as it's overridden for each range iteration evaluation.</p>
</blockquote>
<p>ref: <a href="https://stackoverflow.com/questions/57475521/ingress-yaml-template-returns-error-in-renderring-nil-pointer-evaluating-int">ingress.yaml template returns error in renderring --&gt; nil pointer evaluating interface {}.service</a></p>
<p>That means that we should use <code>$</code> instead of <code>.</code> notation because it references the global scope.</p>
<p>Example:</p>
<pre class="lang-yaml prettyprint-override"><code>{{- include &quot;mychart-stack.fullname&quot; $ }}
</code></pre>
