title: Helm chart fails with "nil pointer evaluating interface {}" when trying to evaluate a missing nested key
body: <p>I am writing a Helm 3 library chart and would like to create a YAML with default values. However, when trying to set a default value for a <strong>nested</strong> key that does not exist, Helm fails with the following error message:</p>
  
  <p><code>nil pointer evaluating interface {}</code></p>
  
  <p>Say I have this snippet in my Kubernetes object:</p>
  
  <pre class="lang-golang prettyprint-override"><code>{{- if eq (.Values.deployment.scale.type | default "static") "static" }}
    replicas: {{ default "3" .Values.deployment.scale.replicas }}
  {{- end }}
  </code></pre>
  
  <p>If <code>.Values.deployment.scale</code> is defined, the template will render fine and the value of <code>replicas</code> will be 3 even if <code>.Values.deployment.scale.replicas</code> is not defined.</p>
  
  <p>However, if one of the parent keys is not defined, Helm will fail with the error message above. For example if <code>values.yaml</code> is the following:</p>
  
  <pre class="lang-yaml prettyprint-override"><code># values.yaml
  deployment:
    not_scale: {}
  </code></pre>
  
  <p>The render will fail with: <code>nil pointer evaluating interface {}.scale</code></p>
  
  <p>How is it possible to set a default value for a nested key, even if its parent keys are undefined?</p>