Why does this working flow generate an error if array is only 1 element in length?

The following flow works, no error...

[{"id":"2821116c.38475e","type":"ui_dropdown","z":"abfc01b.53d8e8","name":"Add","label":"Sessions","tooltip":"","place":"Sessions","group":"2795ce03.741602","order":1,"width":6,"height":1,"passthru":true,"multiple":false,"options":[{"label":"0","value":"{\"Session\":0,\"Zone\":0,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"1","value":"{\"Session\":1,\"Zone\":1,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"2","value":"{\"Session\":2,\"Zone\":2,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"3","value":"{\"Session\":3,\"Zone\":3,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"4","value":"{\"Session\":4,\"Zone\":4,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"}],"payload":"","topic":"","x":510,"y":1100,"wires":[["3efcb411.abdd3c"]]},{"id":"3efcb411.abdd3c","type":"debug","z":"abfc01b.53d8e8","name":"Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":660,"y":1100,"wires":[]},{"id":"b792249a.d7f168","type":"inject","z":"abfc01b.53d8e8","name":"Test","props":[{"p":"options","v":"[{\"5\":\"Test\"},{\"6\":\"Test 2\"}]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":370,"y":1100,"wires":[["2821116c.38475e"]]},{"id":"2795ce03.741602","type":"ui_group","z":"","name":"Schedule","tab":"17746764.02edd9","order":1,"disp":true,"width":6,"collapse":true},{"id":"17746764.02edd9","type":"ui_tab","z":"","name":"Irrigation","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

But the same flow with only 1 element in the array generates an error...

[{"id":"4127c5a3.cdf79c","type":"ui_dropdown","z":"6f7dafdf.3374e","name":"Add","label":"Sessions","tooltip":"","place":"Sessions","group":"2795ce03.741602","order":1,"width":6,"height":1,"passthru":true,"multiple":false,"options":[{"label":"0","value":"{\"Session\":0,\"Zone\":0,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"1","value":"{\"Session\":1,\"Zone\":1,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"2","value":"{\"Session\":2,\"Zone\":2,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"3","value":"{\"Session\":3,\"Zone\":3,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"},{"label":"4","value":"{\"Session\":4,\"Zone\":4,\"Sunday\":true,\"Monday\":true,\"Tuesday\":true,\"Wednesday\":true,\"Thursday\":true,\"Friday\":true,\"Saturday\":true,\"Instances\":1,\"Duration\":4,\"Time\":\"06:00\"}","type":"str"}],"payload":"","topic":"","x":810,"y":300,"wires":[["7af39bcc.4eeca4"]]},{"id":"7af39bcc.4eeca4","type":"debug","z":"6f7dafdf.3374e","name":"Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":960,"y":300,"wires":[]},{"id":"80da868.abca478","type":"inject","z":"6f7dafdf.3374e","name":"Test","props":[{"p":"options","v":"[{\"5\":\"Test\"}]","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":670,"y":300,"wires":[["4127c5a3.cdf79c"]]},{"id":"2795ce03.741602","type":"ui_group","z":"","name":"Schedule","tab":"17746764.02edd9","order":1,"disp":true,"width":6,"collapse":true},{"id":"17746764.02edd9","type":"ui_tab","z":"","name":"Irrigation","icon":"dashboard","order":1,"disabled":false,"hidden":false}]

Error...
9/30/2020, 10:07:47 PMnode: Addmsg : error

"TypeError: Cannot read property 'toString' of null"

Both flows produce errors for me , this because msg.payload is null, try setting msg.payload to 0

That is not the issue. The issue is that if only 1 element in the array, the error results. If the array has 2 elements, no error. Something being parsed weird?

Both flows, as imported, produce that error for me.

As soon as I edit the Inject nodes to set msg.payload to something, the error goes away.

So as far as I can tell, the bug is nothing to do with the length of the array - its whether msg.payload exists or not.

As said i get error with both your flows.

If i give msg.payload a value the errors vanish. The problem is the drop down node throws an error if the pass though message is ticked, the node is trying to read tostring of a null value as there is no msg.payload. A possible bug in the drop down node.

Ah, got catcha. Funny the flows worked for me when I created them, no sure how or why they did not for you.

Which version of dashboard is this ?

2.23.2? Should be latest. Just not at home right now to confirm.