# Global Environment Variables credentials are lost

**URL:** <https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252>\
**Category:** General\
**Created:** [3 January 2024 12:25 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252 "2024-01-03T12:25:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dzm/32/81711_2.png) [@dzm](https://discourse.nodered.org/u/dzm)\
**Post date:** [3 January 2024 12:25 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252/1 "2024-01-03T12:25:41Z")

</div>

(Somewhat related to:  
0. [Reading global environment variable from function node](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619)

1. [Flow Environment credentials are lost](https://discourse.nodered.org/t/flow-environment-credentials-are-lost/80950) )

Hello. I am having trouble reliably using credential values saved as Global Environment Variables.  
First I had the same issue as in (0), where credentials wouldn't be returned at all. Then I've upgraded to Node-RED v3.1.3 and now I am seeing behaviour similar to (1), just there it was happening with flow env variables.

Steps to reproduce:

- add some global variables, set some of them to 'credential' type (  
 ![0-addInitialVars](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd4277f7e8f56071ce99765829a7fea929948aed.png) ),
- add test flow where inject node fills msg properties with values from the global vars (  
 ![1-checkInitialVars](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/086a62f77866dd4f55613097f9234bc742d6357b.png) ) — everything is working fine,
- add another plaintext global variable (  
 ![2-addMoreVars](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/03327a874e9ab7fe86e4b9b0a75c4f9a3fc9bd6b.png) ),
- add the new variable to the test flow (  
 ![3-checkUpdVars](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/b/3bbd7bba28363beeddfdb7d831f758b5f95857b2.png) ) — the global credential variable is lost and has value ` __PWRD__ `.

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [3 January 2024 12:29 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252/2 "2024-01-03T12:29:13Z")

</div>

Nothing has changed since

> [@Reading global environment variable from function node](https://discourse.nodered.org/t/reading-global-environment-variable-from-function-node/81619/6):
>
> I had some time to dig around in the code base: Looks like you fell over an issue in the global env management for credential types. This needs to be fixed; as it is currently, you won't get the credentials value back. I propose you raise an issue in the NR GitHub repo!

Again: I propose you raise an issue in the NR GitHub repo!

---

<div class="post-metadata">

**Author:** ![dzm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dzm/32/81711_2.png) [@dzm](https://discourse.nodered.org/u/dzm)\
**Post date:** [3 January 2024 12:32 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252/3 "2024-01-03T12:32:01Z")

</div>

I thought this was closed in [#4396](https://github.com/node-red/node-red/issues/4396) to be included in [3.1.1 release](https://github.com/node-red/node-red/issues/4396#issuecomment-1788709541).  
This was [the PR](https://github.com/node-red/node-red/pull/4405).

And you are right that such bugs [should probably be reported in the GitHub repo](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md#raising-issues) and not posted here as discussions.

---

<div class="post-metadata">

**Author:** ![dzm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dzm/32/81711_2.png) [@dzm](https://discourse.nodered.org/u/dzm)\
**Post date:** [3 January 2024 12:48 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252/4 "2024-01-03T12:48:28Z")

</div>

Reported as [#4508](https://github.com/node-red/node-red/issues/4508).

---

<div class="post-metadata">

**Author:** ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)\
**Post date:** [3 January 2024 14:28 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252/5 "2024-01-03T14:28:06Z")

</div>

> [@ralphwetzel](#):
>
> Nothing has changed since

> [@dzm](#):
>
> I thought this was closed in [#4396](https://github.com/node-red/node-red/issues/4396) to be included in [3.1.1 release](https://github.com/node-red/node-red/issues/4396#issuecomment-1788709541).

Thank you for this heads-up. Indeed, it seems to be addressed...

> [@dzm](#):
>
> the global credential variable is lost and has value ` __PWRD__ `

This yet looks to be intentional: The credential shouldn't be lost. It's in the nature of (password like) credentials that - once they pass from the client to the runtime - they'll never make their way back.  
Thus you cannot debug them (you'll get ` __PWRD__ ` instead), but you should be able to use them.  
Have you tried?

---

<div class="post-metadata">

**Author:** ![dzm](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dzm/32/81711_2.png) [@dzm](https://discourse.nodered.org/u/dzm)\
**Post date:** [3 January 2024 15:16 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252/6 "2024-01-03T15:16:12Z")

</div>

Should we move this discussion to GitHub? A contributor has [already responded](https://github.com/node-red/node-red/issues/4508#issuecomment-1875500460) with what I think is an explanation that supports my claim.

> Thus you cannot debug them (you'll get ` __PWRD__ ` instead), but you should be able to use them.

I'm not sure how else I'm supposed to use them. In a 'change' or 'function' node I should be able to access the credential value, right? Then I should be able to write that value as a plain text value to msg to be printed to debug.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 March 2024 15:16 UTC](https://discourse.nodered.org/t/global-environment-variables-credentials-are-lost/84252/7 "2024-03-03T15:16:52Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
