<p>When trying to use the helm function: lookup, I do not get any result at all as expected.</p>
<p>My Secret that I try to read looks like this</p>
<pre><code>apiVersion: v1
data:
  adminPassword: VG9wU2VjcmV0UGFzc3dvcmQxIQ==
  adminUser: YWRtaW4=
kind: Secret
metadata:
  annotations:
    sealedsecrets.bitnami.com/cluster-wide: &quot;true&quot;
  name: activemq-artemis-broker-secret
  namespace: common
type: Opaque
</code></pre>
<p>The template helm chart that should load the adminUser and adminPassword data looks like this</p>
<pre><code>apiVersion: broker.amq.io/v1beta1
kind: ActiveMQArtemis
metadata:
  name: {{ .Values.labels.app }}
  namespace: common
spec:
  {{ $secret := lookup &quot;v1&quot; &quot;Secret&quot; .Release.Namespace &quot;activemq-artemis-broker-secret&quot; }}
  adminUser: {{ $secret.data.adminUser }}
  adminPassword: {{ $secret.data.adminPassword }}
</code></pre>
<p>When deploying this using ArgoCD I get the following error:</p>
<pre><code>failed exit status 1: Error: template: broker/templates/deployment.yaml:7:23:
executing &quot;broker/templates/deployment.yaml&quot; at &lt;$secret.data.adminUser&gt;:
nil pointer evaluating interface {}.adminUser Use --debug flag to render out invalid YAML
</code></pre>
<p>Both the secret and the deployment is in the same namespace (common).</p>
<p>If I try to get the secret with kubectl it works as below</p>
<pre><code>kubectl get secret activemq-artemis-broker-secret -n common -o json
{
    &quot;apiVersion&quot;: &quot;v1&quot;,
    &quot;data&quot;: {
        &quot;adminPassword&quot;: &quot;VG9wU2VjcmV0UGFzc3dvcmQxIQ==&quot;,
        &quot;adminUser&quot;: &quot;YWRtaW4=&quot;
    },
    &quot;kind&quot;: &quot;Secret&quot;,
    &quot;metadata&quot;: {
        &quot;annotations&quot;: {
            &quot;sealedsecrets.bitnami.com/cluster-wide&quot;: &quot;true&quot;
        },
        &quot;creationTimestamp&quot;: &quot;2022-10-10T14:40:49Z&quot;,
        &quot;name&quot;: &quot;activemq-artemis-broker-secret&quot;,
        &quot;namespace&quot;: &quot;common&quot;,
        &quot;ownerReferences&quot;: [
            {
                &quot;apiVersion&quot;: &quot;bitnami.com/v1alpha1&quot;,
                &quot;controller&quot;: true,
                &quot;kind&quot;: &quot;SealedSecret&quot;,
                &quot;name&quot;: &quot;activemq-artemis-broker-secret&quot;,
                &quot;uid&quot;: &quot;edff38fb-a966-47a6-a706-cb197ac1797d&quot;
            }
        ],
        &quot;resourceVersion&quot;: &quot;127303988&quot;,
        &quot;uid&quot;: &quot;0679fc5c-7465-4fe1-9197-b483073e93c2&quot;
    },
    &quot;type&quot;: &quot;Opaque&quot;
}
</code></pre>
<p>What is wrong here. I use helm version: 3.8.1 and Go version: 1.75</p>

<p>This error is the result of two parts <em>working</em> together:</p>
<p>First, helm's <code>lookup</code> only works in a running cluster, not when running <code>helm template</code> (without <code>--validate</code>). If run in that manner it returns nil. (It is usually used as <code>lookup ... | default dict {}</code>, to avoid a nasty error message).</p>
<p>Second, you're deploying with ArgoCD that is actually running <code>helm template</code> internally when deploying a helm chart. See open issue: <a href="https://github.com/argoproj/argo-cd/issues/5202" rel="nofollow noreferrer">https://github.com/argoproj/argo-cd/issues/5202</a> . The issue mentions a plugin that can be used to change this behaviour. However, doing so requires some reconfiguration of argocd itself, which is not trivial and is not without side effects.</p>
