Switch with undefined property?


Just noticed something about the switch node and I'm not sure that it is quite right. Or at least not quite as expected from the help.

[{"id":"100238f1.3386f7","type":"inject","z":"fa3e1078.ef619","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":true,"onceDelay":"1","x":150,"y":60,"wires":[["a6eea325.3ec1b"]]},{"id":"a6eea325.3ec1b","type":"switch","z":"fa3e1078.ef619","name":"","property":"fred","propertyType":"msg","rules":[{"t":"eq","v":"naff","vt":"str"},{"t":"null"},{"t":"else"}],"checkall":"true","repair":false,"outputs":3,"x":290,"y":60,"wires":[["b3d407bb.ef2c58"],["e76ff861.4c1448"],["5817b2f6.8024bc","8b5bd9d7.f1a218"]]},{"id":"b3d407bb.ef2c58","type":"debug","z":"fa3e1078.ef619","name":"Is present?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":40,"wires":[]},{"id":"e76ff861.4c1448","type":"debug","z":"fa3e1078.ef619","name":"Is Null?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":480,"y":80,"wires":[]},{"id":"8b5bd9d7.f1a218","type":"debug","z":"fa3e1078.ef619","name":"Otherwise?","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":490,"y":120,"wires":[]}]

The above creates a very simple flow with a trigger, switch and 3 outputs.

The switch is testing a non-existing property of msg. The output happens against the "Is Null?" test. I can kind of see why, there is no property to match on and therefore it might be considered null.

However, the help for the switch node states:

The is true/false and is null rules perform strict comparisons against those types. They do not convert between types.

But that isn't what is happening is it?

Anyway, my request is - should there be an "Is Undefined" test separate to the "Is Null" one?

If not, should the help for the switch node be updated to show that "Is Null" is also triggered if the property being tested doesn't exist.

  • Bump -




Doh! :man_facepalming:t4: :flushed:

When did that appear and how come I'm daft enough not to have spotted it! (Hint: no need to answer the second part).


let you off as it's le weekend.