node-red
node-red copied to clipboard
Jsonata editor test error with transform function (3.1.3)
Current Behavior
I have just updated a node-red server to 3.1.3 and have notice a bug in the JSONata test enviroment in the change node editor.
Prior to update 3.1 this used to work fine.
If you set an array of objects in payload in the test window
{
"payload": [
{
"w1": "This",
"w2": "is",
"w3": "Big!"
},
{
"w1": "Big",
"w2": "as",
"w3": "this?"
}
]
}
Then use this expression containing the transform function
$$.payload ~> |$|
{"a":"a"}
|
An error is reported
Error evaluating expression:
Cannot set properties of null (setting 'a')
The expression will run just fine and produce an output
{
"_msgid": "b5e1ea5de4e4373f",
"payload": [
{
"w1": "This",
"w2": "is",
"w3": "Big!",
"a": "a"
},
{
"w1": "Big",
"w2": "as",
"w3": "this?",
"a": "a"
}
],
"topic": ""
}
I have checked and no error is shown on a node-red 2.3 server, and i am fairly sure it worked on 3.0 to.
Expected Behavior
Not to show error as using tranform function in test panel worked fine prior to update to 3.1.3
Steps To Reproduce
As described above
Example flow
[
{
"id": "d115287648de5277",
"type": "inject",
"z": "d1395164b4eec73e",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[{\"w1\":\"This\",\"w2\":\"is\",\"w3\":\"Big!\"},{\"w1\":\"Big\",\"w2\":\"as\",\"w3\":\"this?\"}]",
"payloadType": "json",
"x": 110,
"y": 2500,
"wires": [
[
"8c8a243c01c3e7b0"
]
]
},
{
"id": "8c71a0febf7bcd4d",
"type": "debug",
"z": "d1395164b4eec73e",
"name": "debug 8",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 660,
"y": 2500,
"wires": []
},
{
"id": "8c8a243c01c3e7b0",
"type": "change",
"z": "d1395164b4eec73e",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$$.payload ~> |$|\t {\"a\":\"a\"}\t|",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 300,
"y": 2500,
"wires": [
[
"8c71a0febf7bcd4d"
]
]
}
]
Environment
- Node-RED version: 3.1.3
- Node.js version: 20.2.0
- npm version: 9.6.6
- Platform/OS: turmux
- Browser: chrome