Only because I am still learning BETTER WAYS TO CODE I am seeing mistakes now and then.
And - alas - some are on the gate node/s. node-red-contrib-simple-gate
Anyway, now and then I am getting messages from said gates about invalid command.
The problem is although I can find the gate..... WHO sent the message?
IDEA
If a node sends a command to the gate, the message has the originating node's ID in the message.
Then - yes, clutching at straws - while I am there and such a thing happens: I can see the node-id of who sent the message and avert the problem for happening again.
Yeah, it is a lot of work for little gain.
But I am making mistakes that now and then crop up and those are the ones which can cause a lot of damage.
Learning how to catch/find the cause is a good way to learn.
(Yes?)
I think the catch only includes the payload from the input message, but that may give you a clue. If not then add a Switch node before the gate, testing for that payload.
It was originally written I think before catching errors was a thing.
Feed the messages you are sending to the gate node also into a Switch node which passes on only gate command messages, and then another which checks the command to be one of the valid ones, and if not then pass to a debug node.
It seems that an invalid command to the gate node results in a warning rather than an error, so you can't detect it with a catch node.
Nor is there a status change so you can't detect it with a status node.
The node could be made more helpful if it raised an error rather than a warning, or if it changed the status, eg by changing the colour to yellow.
Even so, I don't think any node can tell where a particular message came from, unless you add a message property to record it when you send the message.
That is correct and part of the design ethos of Node-RED as I understand it. Then again, I've often had similar issues in the past, though mainly with data going to MQTT and/or a global variable. In those cases, I've tended to add a timestamp and source text to the flow. Indeed, I find this happening with some complex custom node.js/javascript code as well and sometimes add an extra optional text argument to functions that lets me pass through an indication of what is calling the function.
So this is not really an unusual issue with complex logic. Not knowing upstream sources is a fine idea and I actually generally agree with the design approach of node-red. However, like all such ideas, it is never going to be 100% the right idea.
This would have to be added as an OPTION to the node's configuration. Making it a new default would likely break a lot of existing flows. But yes, probably a good idea to have it.
Written by our friend @drmibell - though I see his last post in the forum was late 2023? So not sure he is still working with Node-RED? Also the package hasn't been updated in a long time and has several outstanding issues.
So worth putting in an issue but someone might need to fork the node if there is no response.
This is also the best I could come up with. At least you will have evidence of what the invalid command is, this may give you a clue as to the originator,