Read file node ignores msg.filename

According to the documentation of the "read file" node it should take the file to read from msg.filename by default. This doesn't seem to work on my end unless I specifically set it in the properties of the node. Does anyone experience this problem? I'm running 3.0.2.

"The name of the file to be read can be provided in the node configuration, or as a message property. By default it will use msg.filename but this can be customised in the node."

If you use msg.filename, the property field in the node should be blank.

filename string
if not set in the node configuration, this property sets the filename to read.

This looks like it was broken at the 3.0 release, will try and look at fixing it later, but if you can raise an issue here Sign in to GitHub · GitHub it will mean it doesn't get missed

Thanks for the heads up. I've created the following ticket: #3910

This was a change in behaviour as detailed in v3 Beta file node typed input defaults to msg. rather than string type · Issue #3668 · node-red/node-red · GitHub

Unfortunately the help text did not get updated to match the change in behaviour. We will use this issue to fix the help text to properly describe the default behaviour.

Thanks for the clarification, as a 'naive' user I was using the old behavior ;).

Expected msg.filename to take precedence over the property set on the node. This way it plays nicely with the 'watch' node without having to configure the 'read file' node. Isn't this causing backwards compatibility issues for users?

It will only apply to newly added nodes - existing nodes already have their configuration set to do what they do.

No, if an existing node-red server is updated, the flows continue as before. It does this compatibility check internally since it recognises certain (new v3) properties are missing.

Thanks for clarifying

Would it be an idea to make 'filename' the initial value when setting the Filename property to msg? This would basically be similar to the Output property of the Debug node (in that case 'payload').

1 Like

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