Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty subflow property used in config for node in subflow replaced with ${<name>} instead of empty string #4663

Open
colinl opened this issue Apr 20, 2024 · 4 comments
Labels

Comments

@colinl
Copy link
Contributor

colinl commented Apr 20, 2024

Current Behavior

If a subflow property is left empty and is used in a contained node config as ${name} then that is replaced with the text ${name} instead of an empty string.
I am using it to pass a class to a contained dashboard 2 node and the result is that it ends up with a class of ${class}.

Expected Behavior

It should be an empty string, I think.

Steps To Reproduce

Import the flow below and run it.

Example flow

[{"id":"0a1d6e22b709848d","type":"subflow","name":"Empty property test","info":"","category":"","in":[],"out":[{"x":400,"y":80,"wires":[{"id":"48fce04ebb8a6bbe","port":0}]},{"x":400,"y":180,"wires":[{"id":"14b4297f97abdf9c","port":0}]}],"env":[{"name":"value1","type":"str","value":""},{"name":"value2","type":"str","value":""}],"meta":{},"color":"#DDAA99"},{"id":"48fce04ebb8a6bbe","type":"inject","z":"0a1d6e22b709848d","name":"","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"${value1}","payloadType":"str","x":210,"y":80,"wires":[[]]},{"id":"14b4297f97abdf9c","type":"inject","z":"0a1d6e22b709848d","name":"","props":[{"p":"payload"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"${value2}","payloadType":"str","x":210,"y":180,"wires":[[]]},{"id":"ad46caabb2f31ef4","type":"debug","z":"33d99109.14b49e","name":"VALUE 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":640,"y":400,"wires":[]},{"id":"9dc2dc5cebac6292","type":"debug","z":"33d99109.14b49e","name":"VALUE 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":640,"y":460,"wires":[]},{"id":"cafd616b39449568","type":"subflow:0a1d6e22b709848d","z":"33d99109.14b49e","name":"empty property test","env":[{"name":"value2","value":"v2","type":"str"}],"x":350,"y":440,"wires":[["ad46caabb2f31ef4"],["9dc2dc5cebac6292"]]}]

Environment

  • Node-RED version: 3.1.9 and 4.0.0-Beta.2
  • Node.js version: 16 and 20
  • npm version:
  • Platform/OS:Ubuntu on laptop and Pi OS on Pi
  • Browser: Edge
@knolleary
Copy link
Member

This is how we've always handled env-var substitution into node properties if the env var is blank. It isn't specific to subflows, or the config node option.

If you change the typedInput to env type, then it will evaluate to an empty string:

image

@colinl
Copy link
Contributor Author

colinl commented Apr 24, 2024

In D2 ui-template the class field is not a typed input, so I can't do that.
image

There is a workaround, by adding a node in front of the template that sets message.class from the env var instead.

@knolleary
Copy link
Member

I've opened #4672 for 4.0 that will allow blank strings to be inserted via env vars. Undefined env vars will still leave the ${FOO} value untouched.

@colinl
Copy link
Contributor Author

colinl commented Apr 25, 2024

Thanks.
For the record, for typed inputs, setting it as Env Var type works, though the syntax is
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants