node-red/node-red-nodes

JSONata not evaluated in write file node in 3.1.0 beta3

rvangeijtenbeek opened this issue · 1 comments

Which node are you reporting an issue on?

write file

What are the steps to reproduce?

Use Node-RED 3.1.0 beta 3. Load the three-node testcase:
[{"id":"c5d75c36b6f6846c","type":"file","z":"ab3c7ced726901fd","name":"write file to expression-defined location","filename":"'/data/test/' & 'test.txt'","filenameType":"jsonata","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":450,"y":60,"wires":[["48292418.2b6f34"]]},{"id":"22ccdcc7.90b7a4","type":"inject","z":"ab3c7ced726901fd","name":"write payload to test.txt","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"write payload to test.txt","payload":"this is a test","payloadType":"str","x":160,"y":60,"wires":[["c5d75c36b6f6846c"]]},{"id":"48292418.2b6f34","type":"debug","z":"ab3c7ced726901fd","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":690,"y":60,"wires":[]}]

Basically, the write file node uses this JSONata expression to set Filename:
'/data/test/' & 'test.txt'

What happens?

In Node-RED v3.1.0-beta3, the 'write file' node in the test is using a JSONata expression to set the file path. But in my Windows 11 system, the JSONata expression isn't evaluated but passed along 'as is' as a file path. The means Windows creates a folder named ' (comma), then subfolders 'data' and 'test', and the filename ' & 'test.txt'

What do you expect to happen?

The JSONata expression getting evaluated, so the file path becomes data/test/test.txt

Note that this works fine on Node-RED 3.0.2 on Windows or Docker. I did not try to update my Node-RED docker contrainer to 3.1.0-beta3.

Please tell us about your environment:

  • [ x] Node-RED version: v3.1.0-beta.3
  • [ x] node.js version: v18.16.0
  • [ x] npm version: 9.2.0
  • [ x] Platform/OS: Windows 11 Enterprise (on VMWare)
  • [ x] Browser: Edge

This will be addressed via node-red/node-red#4246

Note that any issues with core nodes should be raised here: https://github.com/node-red/node-red/.

This repo is for the extra nodes that are not installed by default.