# Env var replacement for empty strings

**URL:** https://discourse.nodered.org/t/env-var-replacement-for-empty-strings/65739
**Category:** Feature Requests
**Created:** [28 July 2022 09:32 UTC](https://discourse.nodered.org/t/env-var-replacement-for-empty-strings/65739 "2022-07-28T09:32:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![JbIPS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbips/32/9246_2.png) [@JbIPS](https://discourse.nodered.org/u/JbIPS)
#### Post date: [28 July 2022 09:32 UTC](https://discourse.nodered.org/t/env-var-replacement-for-empty-strings/65739/1 "2022-07-28T09:32:07Z")

</div>

When the value of an env var is an empty string, the ternary operator [here](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/runtime/lib/flows/util.js#L60) will consider the empty string a falsy value, resulting in the variable not being replaced.

If we specifically test for `undefined` (like [here](https://github.com/JbIPS/node-red/blob/master/packages/node_modules/%40node-red/runtime/lib/flows/util.js#L60)), the empty string will be preserved and only missing env variables would be discarded.

Is it OK for a PR?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 July 2022 10:34 UTC](https://discourse.nodered.org/t/env-var-replacement-for-empty-strings/65739/2 "2022-07-28T10:34:22Z")

</div>

That would be a breaking change as there will be flows that rely on leaving an env var 'blank' in order to fall back to the parent value.

---

<div class="post-metadata">

### Author: ![JbIPS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jbips/32/9246_2.png) [@JbIPS](https://discourse.nodered.org/u/JbIPS)
#### Post date: [28 July 2022 10:45 UTC](https://discourse.nodered.org/t/env-var-replacement-for-empty-strings/65739/3 "2022-07-28T10:45:45Z")

</div>

That's right. Would there be a workaround in order to work with empty strings?

---

<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: [26 September 2022 10:46 UTC](https://discourse.nodered.org/t/env-var-replacement-for-empty-strings/65739/4 "2022-09-26T10:46:18Z")

</div>

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