Repository navigation
Description
Current Behavior
There seems to be an issue with the CSV node when handling messages that include the msg.parts property. The msg.parts originates from a previous split node to parse multiple CSV files. I have identified four different test scenarios that demonstrate the issue, which I've detailed below.
Expected Behavior
The CSV node should process the single-lined csv and output the parsed data.
Steps To Reproduce
- Test Scenario 1: Single Line CSV with msg.parts
- Inject a message with a single line CSV payload and a msg.parts property originates from splitting multiple files.
- Expected Result: The CSV node should process the line and output the parsed data.
- Actual Result: No message is output from the CSV node.
- Test Scenario 2: Single Line CSV with Deleted msg.parts
- Inject the same message as Scenario 1, but delete the msg.parts property before it reaches the CSV node.
- Expected Result: The CSV node processes the line and outputs the parsed data correctly.
- Actual Result: The CSV node outputs the parsed data as expected.
- Test Scenario 3: Adjusted msg.parts with Count = 1
- Inject a message with a single line CSV payload and a msg.parts property where count=1 and index=0.
- Expected Result: The CSV node should process the line and output the parsed data.
- Actual Result: The CSV node outputs an empty array instead of the expected parsed data.
- Test Scenario 4: Multi-line CSV
- Inject a message with a multi-line CSV payload and a msg.parts property originates from splitting multiple files.
- Expected Result: The CSV node should process the lines and output the parsed data for each line.
- Actual Result: The CSV node functions as expected and outputs the parsed data for each line.
In all four test scenarios, the CSV node is configured to output one message for all rows ("multi": "mult").
Example flow
[{"id":"c8a655cce7872291","type":"inject","z":"c99a73116a9a3dfe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":200,"wires":[["bb13fe4c6d68a33b"]]},{"id":"bb13fe4c6d68a33b","type":"function","z":"c99a73116a9a3dfe","name":"payload","func":"msg = {\n \"payload\": \"one,two,three\\n\",\n \"topic\": \"\",\n \"parts\": {\n \"id\": \"ec25ba94d947cd82\",\n \"type\": \"array\",\n \"count\": 19,\n \"len\": 1,\n \"index\": 6\n },\n \"_msgid\": \"c111ed6c939783c7\"\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":200,"wires":[["c9a9e2e7d2115b0a"]]},{"id":"b9e1917066925ff7","type":"debug","z":"c99a73116a9a3dfe","name":"doesnt work","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1170,"y":200,"wires":[]},{"id":"e04e920151d80810","type":"inject","z":"c99a73116a9a3dfe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":260,"wires":[["9168eea8fe196d9b"]]},{"id":"9168eea8fe196d9b","type":"function","z":"c99a73116a9a3dfe","name":"payload","func":"msg = {\n \"payload\": \"one,two,three\\n\",\n \"topic\": \"\",\n \"parts\": {\n \"id\": \"ec25ba94d947cd82\",\n \"type\": \"array\",\n \"count\": 19,\n \"len\": 1,\n \"index\": 6\n },\n \"_msgid\": \"c111ed6c939783c7\"\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":260,"wires":[["4cec5c2e7d3055dd"]]},{"id":"27431f17081da278","type":"debug","z":"c99a73116a9a3dfe","name":"works","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":260,"wires":[]},{"id":"4cec5c2e7d3055dd","type":"change","z":"c99a73116a9a3dfe","name":"delete parts","rules":[{"t":"delete","p":"parts","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":260,"wires":[["9c491b0724e749c0"]]},{"id":"a856435392afec31","type":"function","z":"c99a73116a9a3dfe","name":"payload","func":"msg = {\n \"payload\": \"one,two,three\\none,two,three\\n\",\n \"topic\": \"\",\n \"parts\": {\n \"id\": \"ec25ba94d947cd82\",\n \"type\": \"array\",\n \"count\": 19,\n \"len\": 1,\n \"index\": 6\n },\n \"_msgid\": \"c111ed6c939783c7\"\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":500,"wires":[["97ca567c09c37efc"]]},{"id":"285741dc1e1de769","type":"inject","z":"c99a73116a9a3dfe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":500,"wires":[["a856435392afec31"]]},{"id":"97ca567c09c37efc","type":"csv","z":"c99a73116a9a3dfe","name":"","sep":",","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":false,"include_empty_strings":"","include_null_values":"","x":910,"y":500,"wires":[["1bb12280ddbfc201"]]},{"id":"1bb12280ddbfc201","type":"debug","z":"c99a73116a9a3dfe","name":"works","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1190,"y":500,"wires":[]},{"id":"7aeb2077d63f4706","type":"comment","z":"c99a73116a9a3dfe","name":"one row csv","info":"","x":330,"y":140,"wires":[]},{"id":"53c4123ca1f6e875","type":"comment","z":"c99a73116a9a3dfe","name":"two rows csv","info":"","x":330,"y":440,"wires":[]},{"id":"c9a9e2e7d2115b0a","type":"csv","z":"c99a73116a9a3dfe","name":"","sep":",","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":false,"include_empty_strings":"","include_null_values":"","x":910,"y":200,"wires":[["b9e1917066925ff7"]]},{"id":"9c491b0724e749c0","type":"csv","z":"c99a73116a9a3dfe","name":"","sep":",","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":false,"include_empty_strings":"","include_null_values":"","x":910,"y":260,"wires":[["27431f17081da278"]]},{"id":"95d104420ee392e5","type":"inject","z":"c99a73116a9a3dfe","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":340,"y":320,"wires":[["25cbe31beca861af"]]},{"id":"25cbe31beca861af","type":"function","z":"c99a73116a9a3dfe","name":"payload","func":"msg = {\n \"payload\": \"one,two,three\\n\",\n \"topic\": \"\",\n \"parts\": {\n \"id\": \"ec25ba94d947cd82\",\n \"type\": \"array\",\n \"count\": 1,\n \"len\": 1,\n \"index\": 0\n },\n \"_msgid\": \"c111ed6c939783c7\"\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":320,"wires":[["4ae875d40670a42b"]]},{"id":"6544cb71b8738b2d","type":"debug","z":"c99a73116a9a3dfe","name":"count = 1 -> empty array","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1130,"y":320,"wires":[]},{"id":"4ae875d40670a42b","type":"csv","z":"c99a73116a9a3dfe","name":"","sep":",","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":false,"include_empty_strings":"","include_null_values":"","x":910,"y":320,"wires":[["6544cb71b8738b2d"]]}]Environment
- Node-RED version: 4.0.0-beta.3-1
- Node.js version: 20.13.1
- npm version: 10.5.2
- Platform/OS: Alpine Linux, 3.19.1
- Browser: Microsoft Edge, 126.0.2592.61
Activity
knolleary commentedon Jun 20, 2024
Do you know if these are scenarios that worked in 3.1 and this is a regression, or if these scenarios never worked so its a bug.
We were going to do the 4.0 release today. If this is a regression, we'll want to address it before release. If it's an existing bug, we can release 4.0 as-is and handle this as a bug fix.
dumdiedum commentedon Jun 20, 2024
I can try this in a 2x version of nodered, I will answer in around two hours
knolleary commentedon Jun 20, 2024
@dumdiedum its the 3.x stream I'm most interested in - not 2.x :)
dumdiedum commentedon Jun 20, 2024
Sorry, then I can't help out
knolleary commentedon Jun 20, 2024
@dumdiedum no problem - I'll run your flows in 4.x and 3.x and compare results.
knolleary commentedon Jun 20, 2024
The flows behaviour the same in 3.1.x as they do in 4.x. So this is not a regression in the CSV node (which received quite a few updates in 4.0).
As a preexisting issue, I'm not going to hold-up the 4.0 release today for it. We can address in a maintenance release.