Drag&Drop handling of JSON string that isn't an array of nodes

Hi There,

When I drag and drop the string "[0]" (with or without the quotes) onto Node-RED workspace, I get this error:

Screenshot 2024-11-17 at 16.17.43

(or e.type is undefined depending on the minification of the .js.)

This was using NR 4.0.5.

What is happening is that the drag&drop behaviour assumes that if the content can be parsed as valid JSON then it must be an array of nodes.

I as a user have no idea why that is happening nor does the error message help me, all I did was drag JSON content onto the workspace.

The cause of the error is this line in RED.node.import and this code is displaying the error message.

It might be better to ignore that error and not display it to the user. Drops that aren't handled are also silently ignored, i.e., the user won't necessarily expect feedback to be generated from their drop.

Sure the console could display the whole error instead of just the stack trace.

But, your case is related to your drag and drop plugin, the core uses drag and drop to import flows. It is not supposed to support anything else (on the workspace).

The common error when importing is a malformed JSON flow and there the error is notified via a more understandable message by the user.

But images can also be drag&dropped into the editor. So flows aren't the only thing being dragged onto the workspace.

I don't get an error when dragging malformed JSON, I get nothing. No message, no flow, just silence. That's also unexpected behaviour.

Perhaps a PR to enhance the error message might be useful?

Best place to report a bug is the GitHub issue tracker.

Editor is not the workspace.

Yeah strange, will investigate later. I have the error in the console only.

Depends on what the core is supposed to handle.

1 Like

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