<p>We are deploying with Ansible scripts to Openshift 3 using <code>oc apply</code>. When we change template to add more environment variables, we receive a very vague error: <code>&quot;unrecognized type: string&quot;</code> and status code 500.</p>
<p>Setting <code>--loglevel 10</code> leads to no more details:</p>
<pre><code>$ /usr/local/bin/oc_v3.11.715 apply -f \&quot;/tmp/ansible.YtEqVm_deploy/app.yml.json\&quot; -n test-env --loglevel 10 2&amp;&gt; log.log

(several GET to get secret, deploymentconfigs, etc.)
...
I0127 11:49:05.455217     605 request.go:897] Request Body: {xxxxxxxx}
I0127 11:49:05.455280     605 round_trippers.go:386] curl -k -v -XPATCH  -H &quot;User-Agent: oc_v3.11.715/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0&quot; -H &quot;Authorization: Bearer xxxxxx&quot; -H &quot;Accept: application/json&quot; -H &quot;Content-Type: application/strategic-merge-patch+json&quot; 'https://test-env:8443/apis/apps.openshift.io/v1/namespaces/test-app/deploymentconfigs/app'
I0127 11:49:05.466278     605 round_trippers.go:405] PATCH https://test-env:8443/apis/apps.openshift.io/v1/namespaces/test-env-app/deploymentconfigs/app 500 Internal Server Error in 10 milliseconds
I0127 11:49:05.466287     605 round_trippers.go:411] Response Headers:
I0127 11:49:05.466291     605 round_trippers.go:414]     Content-Length: 118
I0127 11:49:05.466294     605 round_trippers.go:414]     Date: Fri, 27 Jan 2023 09:49:05 GMT
I0127 11:49:05.466297     605 round_trippers.go:414]     Audit-Id: 1d3f3398-14fc-4bfa-854b-6faf9b105680
I0127 11:49:05.466302     605 round_trippers.go:414]     Cache-Control: no-store
I0127 11:49:05.466307     605 round_trippers.go:414]     Content-Type: application/json
I0127 11:49:05.466321     605 request.go:897] Response Body: {&quot;kind&quot;:&quot;Status&quot;,&quot;apiVersion&quot;:&quot;v1&quot;,&quot;metadata&quot;:{},&quot;status&quot;:&quot;Failure&quot;,&quot;message&quot;:&quot;unrecognized type: string&quot;,&quot;code&quot;:500}
I0127 11:49:05.466603     605 helpers.go:201] server response object: [{
  &quot;kind&quot;: &quot;Status&quot;,
  &quot;apiVersion&quot;: &quot;v1&quot;,
  &quot;metadata&quot;: {},
  &quot;status&quot;: &quot;Failure&quot;,
  &quot;message&quot;: &quot;unrecognized type: string&quot;,
  &quot;code&quot;: 500
}]
F0127 11:49:05.466618     605 helpers.go:119] Error from server: unrecognized type: string
</code></pre>
<p>The request body is like:</p>
<pre class="lang-json prettyprint-override"><code>{
    &quot;metadata&quot;: {
        &quot;annotations&quot;: {
            &quot;kubectl.kubernetes.io/last-applied-configuration&quot;: &quot;xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&quot;
        }
    },
    &quot;spec&quot;: {
        &quot;template&quot;: {
            &quot;spec&quot;: {
                &quot;$setElementOrder/containers&quot;: [{
                    &quot;name&quot;: &quot;app&quot;
                }],
                &quot;containers&quot;: [{
                    &quot;$setElementOrder/env&quot;: [{
                        &quot;name&quot;: &quot;OLD_VAR_1&quot;
                    }, {
                        &quot;name&quot;: &quot;OLD_VAR_2&quot;
                    }, {
                        &quot;name&quot;: &quot;OLD_VAR_3&quot;
                    }, {
                        &quot;name&quot;: &quot;OLD_VAR_4&quot;
                    }, {
                        &quot;name&quot;: &quot;NEW_VAR_1&quot;
                    }, {
                        &quot;name&quot;: &quot;NEW_VAR_2&quot;
                    }, {
                        &quot;name&quot;: &quot;NEW_VAR_3&quot;
                    }],
                    &quot;dnsPolicy&quot;: &quot;ClusterFirst&quot;,
                    &quot;env&quot;: [{
                        &quot;name&quot;: &quot;OLD_VAR_4&quot;,
                        &quot;value&quot;: false
                    }, {
                        &quot;name&quot;: &quot;NEW_VAR_1&quot;,
                        &quot;value&quot;: 10
                    }, {
                        &quot;name&quot;: &quot;NEW_VAR_2&quot;,
                        &quot;value&quot;: 20
                    }, {
                        &quot;name&quot;: &quot;NEW_VAR_3&quot;,
                        &quot;value&quot;: 6
                    }],
                    &quot;name&quot;: &quot;app&quot;,
                    &quot;restartPolicy&quot;: &quot;Always&quot;,
                    &quot;terminationGracePeriodSeconds&quot;: 300
                }]
            }
        }
    }
}
</code></pre>
<p><code>OLD_VAR_x</code> are old environment variables; we want to add <code>NEW_VAR_[1-3]</code>. Notice strangely that not all old vars are in <code>env</code>, only <code>OLD_VAR_4</code>, but all new vars are in <code>env</code>.</p>
<p>This also happens when we use <code>oc patch</code> with the same request body. Same error response.</p>
<p>What is wrong?</p>
<p>A workaround is first, deployment, fail, and add new vars in Openshift manually, and deploy in Openshift webconsole on top of the last, failed deployment. It works.</p>

WesternGun
<p>Solved by quoting the var values in the template, like:</p>
<pre><code>- name: NEW_VAR_X
  value: &quot;${NEW_VAR_VALUE_X}&quot;
</code></pre>
<p>No errors ever since.</p>
