New thing: Flow Inspector

We are all familiar with the issue of a flow being shared in the forum without any information about what it contains. It isn't easy to stare at the JSON to figure these things out. In particular, the question over what contrib nodes it depends on.

I've put together an experimental page in the flow library to try to help. You paste in the flow and it gives back a report about what the flow contains. It looks up each node type to say which module it comes from.

https://flows.nodered.org/inspect

For example, pasting in this flow (picked at random), you get:

Flows: 1
Subflows: 1
Nodes: 35

 Type                    | Count | Module
-------------------------|-------|-------------------
 comment                 |     2 | @node-red/nodes
 debug                   |     1 | @node-red/nodes
 function                |    12 | @node-red/nodes
 inject                  |     3 | @node-red/nodes
 schedex                 |     1 | node-red-contrib-schedex
 ui_group                |     1 | node-red-dashboard
 ui_button               |     3 | node-red-dashboard
 ui_switch               |     7 | node-red-dashboard
 ui_tab                  |     1 | node-red-dashboard
 ui_text_input           |     2 | node-red-dashboard
 ui_toast                |     1 | node-red-dashboard
 subflow:3abe8c84.455934 |     1 | 


Modules:
 - node-red-contrib-schedex
 - node-red-dashboard

When a node type is provided by multiple modules it does try to infer the right one. For example, above you can see node-red-dashboard is listed. Some of those ui_xyz nodes are provided by multiple modules that have cloned dashboard. However only ui_group is provided by node-red-dashboard, so the code infers it must be the module providing the others.

This is a quickly hacked together idea, I'm sure there's more it could do. Ideas/contributions etc are welcome.

Here's the code for the page: https://github.com/node-red/flow-library/blob/master/template/flowInspector.html

15 Likes

Excellent Nick!

I like it.

Nick, could a potential workaround to inference be in a future version of node-red add a property that explicitly identifies the original node (in the JSON export)? I'm not certain about the possibility or impact or where this would need to be implemented (in each node or the core) but if it is something that could be added easily, it might open other possibilities (like option download and install missing nodes for example?)

Just a thought.

Yup, one that has been discussed many times to no ultimate conclusion. Hence why, 5 years later, we still don't do it.

1 Like

Yeah I know it was an obvious one but thought it worth mentioning

Great facility :slight_smile:

[edit]

Maybe add it to main menu or prominent link of https://flows.nodered.org/

1 Like

Just used it in anger for first time to find out what a missing contrib node was in a flow that someone wants help with :slight_smile:
image

3 Likes

I used it earlier. Extremely useful.
Now if you could just right click a flow in the forum and have that popup then that would be the icing on the cake :slight_smile:
I guess that would rely on discourse providing a hook to connect to so maybe it isn't even possible.

I'm waiting for a suitably wet evening before I go read up on writing discourse plugins....

1 Like

It's perfect coding weather up here at the moment :frowning:

Love it!

Of course, inevitably I'll ask for more :frowning:

A nice, small enhancement would be to add a link to the appropriate place in the flows library for the identified nodes. Might need to be a search link though as I note that some nodes use npm scopes which are included in the URL - a search URL would therefore likely be simpler to implement.

Looks like it would just need a small change on line 129. Happy to do a PR for you if you agree it worthwhile.

@TotallyInformation its trivial to add a link to the modules - scopes are no issue. I held back initially because I was trying to keep the output valid markdown so it could be copy/pasted into the forum. Once you start adding markdown links, it because less readable in the raw markdown format. No real need to keep it as markdown for now - so go ahead with a PR

1 Like

Done.

However, apologies but I can't actually test this change at the moment as I don't have a docker environment available.

In particular, it would be good to find a flow that contains a scoped node.

The link is only added to the modules summary at the end and is set to open the appropriate entry in the flows library in a new tab.

Thanks Julian - although it isn't quite that simple. The report being generated at that point is treated as plain text, so any HTML in it will be displayed raw.

I'll stick something in later for it.

Ah, OK. Such is life! :grinning:

Nice, I see you've already updated it Nick!

Now all you need to do is add a diagramming library so you can draw out the flow without needing Node-RED :rofl:

Just kidding - well, unless you are really bored ...

2 Likes

@knolleary One small nit with this, it sometimes will report a node that is not in the flow. Take this flow;

[{"id":"f07be5c0.6e40b","type":"tab","label":"Flow 17","disabled":false,"info":""},{"id":"66e2a3fb.68a234","type":"inject","z":"f07be5c0.6e40b","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":120,"wires":[["aaa9daf4.424fa8"]]},{"id":"9660353a.d1e858","type":"debug","z":"f07be5c0.6e40b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":560,"y":120,"wires":[]},{"id":"aaa9daf4.424fa8","type":"random","z":"f07be5c0.6e40b","name":"","low":"1","high":"10","inte":"true","property":"payload","x":400,"y":140,"wires":[["9660353a.d1e858"]]}]

it's a simple inject -> random -> debug but when you run it thru the inspector it shows:

Flows: 1
Nodes: 3

 Type     | Count | Module
----------|-------|-------------------
 debug    |     1 | @node-red/nodes
 inject   |     1 | @node-red/nodes
 random   |     1 | node-red-node-random, node-red-contrib-viseo-random

Modules:
 - node-red-node-random, node-red-contrib-viseo-random

but node-red-contrib-viseo-random is not installed at all.

And if there is a flow using the moment node you get back: node-red-contrib-moment, node-red-contrib-moment-bug_locale, node-red-contrib-moment2

Just thought I'd point this out.

They are all node modules that could provide a node of that name.

True...but you wouldn't know which one the user used nd they could do different things or be missing an option or have an option that is not set.