Jsonata expression is not validated in Switch node Property field

If I put this Jsonata expression into a Change node the red border flags it as invalid
Untitled 1
But in the Property field of a switch node there is no red border and the node is successfully deployed.

However, the node presumably errors (silently) at runtime since there is no message output from either line.

[{"id":"9abbf6045584a050","type":"inject","z":"142f935612b6e391","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"BBB","payload":"AAA","payloadType":"str","x":120,"y":60,"wires":[["568c6a2a67c3b5d3"]]},{"id":"568c6a2a67c3b5d3","type":"switch","z":"142f935612b6e391","name":"","property":"{{payload}} & {{topic}}","propertyType":"jsonata","rules":[{"t":"eq","v":"AAABBB","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":60,"wires":[["43256a20bf961d71"],["b9990a554a15866e"]]},{"id":"43256a20bf961d71","type":"debug","z":"142f935612b6e391","name":"debug 398","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":40,"wires":[]},{"id":"b9990a554a15866e","type":"debug","z":"142f935612b6e391","name":"debug 399","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":430,"y":80,"wires":[]}]

If the evaluation of a switch node expression gives an error, shouldn't evaluation continue to the next rather than just stopping?

Note that if you modify the internals of the change node and deploy, there is an error in the debug pane, but no red flag on the node. If you just move the node and deploy, no error message.

Should that be payload & topic
Flags {{payload}} & {{topic}} as invalid in switch node for me, node-red version 3.0.2
The switch does not show red triangle though


When I import your flow into NR (v3.1.0) I get a error showing up in the debug sidebar:

Try this in the switch:
Screenshot 2023-09-11 at 9.46.08 AM

Yes, thanks (both of you) I did eventually discover the right syntax, I was posting to report what seems to be a bug.

I'm not clear if the images you posted relate to run time or deploy.
I did point out

Note that if you modify the internals of the change node and deploy, there is an error in the debug pane, but no red flag on the node.

Top 1 debug deploy switch only invalid expression, next is run with correct expression in switch only, then added change node, last 2 deploy both change and switch invalid expressions.
Seems to be bug in switch not showing triangle, will upgrade to 3.1.0 next weekend, and check again, if somebody else has not already by then.

Shows as an error for me:

image

v3.1.0

What about the red triangle on the node?

No, that doesn't show. But I don't think a JSONata syntax error shows an invalid node on any node?

image

But they do give errors (to debug and console):

image

It does on a change node, see my images above.

Indeed:

image

OK yes, if I type {{payload}} & {{topic}} into either or both the Property field or a switch condition, the outline is red and at deploy there is a warning in the debug pane.
There is no red triangle flag on the node from either of these errors.

After deploy, back into the node, the border round the Property field is grey while the switch condition outline is still red (Property field is not verified when the node is opened?)

The moment I click in the Property field the border changes to blue (Bad assumption that validation has passed?)

It stays blue as I edit the field.

Observed on NR 3.1.0, not tested on 3.0.2

Confirmed.

You are correct, looks at least to be an inconsistent design if not a bug. :slight_smile:

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