在 util.setObjectProperty 中在数组路径上出现了未捕获的 TypeError
作者: codeCraft-Ritik创建于 2026年9月8日更新于 2026年9月8日
标签needs-triage
- Call
util.setObjectPropertyon an object containing an array with anullor primitive value:
const util = require('@node-red/util').util;
const msg1 = { arr: [null] };
util.setObjectProperty(msg1, 'arr[0].subprop.leaf', 123);
const msg2 = { arr: [123] };
util.setObjectProperty(msg2, 'arr[0].subprop.leaf.deep', 456);
const msg3 = { arr: [null] };
util.setObjectProperty(msg3, 'arr[0].subprop');
```2. Observe that Node-RED throws an uncaught `TypeError` and terminates the process instead of returning `false`.
---
```json
[
{
"id": "tab_setobjectproperty_repro",
"type": "tab",
"label": "Repro: setObjectProperty Crash",
"disabled": false,
"info": ""
},
{
"id": "inject_null_array",
"type": "inject",
"z": "tab_setobjectproperty_repro",
"name": "Send Array with Null",
"props": [
{
"p": "payload",
"v": "{\"arr\":[null]}",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 190,
"y": 140,
"wires": [
[
"change_deep_prop"
]
]
},
{
"id": "change_deep_prop",
"type": "change",
"z": "tab_setobjectproperty_repro",
"name": "Set deep prop: payload.arr[0].subprop.leaf",
"rules": [
{
"t": "set",
"p":
…内容来源: node-red/node-red