node-red / node-red-dashboard

A dashboard UI for Node-RED
Other
1.32k stars 453 forks source link

Whole Nodered isntance crashing with parameters of bad type #800

Closed hyamanieu closed 1 year ago

hyamanieu commented 1 year ago

What are the steps to reproduce?

Please note this also happens when passing an "integer" when a string is imposed or vice-versa.

What happens?

The whole Nodered instance is crashing.

here's the log:

The whole instance is crashing

14 Mar 09:35:30 - [red] Uncaught Exception: 14 Mar 09:35:30 - [error] TypeError: Cannot read properties of undefined (reading 'mitarbeiter') at /usr/src/node-red/node_modules/@node-red/util/lib/util.js:430:29 at Array.reduce () at getObjectProperty (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:429:18) at getMessageProperty (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:401:12) at Object.evaluateNodeProperty (/usr/src/node-red/node_modules/@node-red/util/lib/util.js:652:22) at Object.beforeSend (/data/node_modules/node-red-dashboard/nodes/ui_dropdown.js:183:34) at EventEmitter.handler (/data/node_modules/node-red-dashboard/ui.js:288:22) at EventEmitter.emit (node:events:539:35) at Socket.emit (node:events:527:28) at Socket.emitUntyped (/data/node_modules/socket.io/dist/typed-events.js:69:22) at /data/node_modules/socket.io/dist/socket.js:614:39 at processTicksAndRejections (node:internal/process/task_queues:78:11) 14 Mar 09:35:31 - [info]

What do you expect to happen?

Errors should always be caught and an error message should be passed to the debugger! A library should not crash a whole Nodered instance, whatever the bug.

Please tell us about your environment:

hyamanieu commented 1 year ago

May be linked to:

dceejay commented 1 year ago

Can you share a small flow that shows this ? I am unable to get it to fail based on a simple inject of null or [] Thanks

hyamanieu commented 1 year ago

Thanks for responding so quickly! Here's an importable code sample:

[
    {
        "id": "a72683cc5cd6f15e",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "31692e835acece2c",
        "type": "ui_dropdown",
        "z": "a72683cc5cd6f15e",
        "name": "",
        "label": "mitarbeiter",
        "tooltip": "Mitarbeiter Anmelden",
        "place": "auswählen",
        "group": "e2459ea6aab21c76",
        "order": 2,
        "width": 6,
        "height": 1,
        "passthru": true,
        "multiple": false,
        "options": [
            {
                "label": "",
                "value": "",
                "type": "str"
            }
        ],
        "payload": "",
        "topic": "payload.mitarbeiter",
        "topicType": "msg",
        "className": "",
        "x": 910,
        "y": 500,
        "wires": [
            []
        ]
    },
    {
        "id": "48292bafe507e974",
        "type": "change",
        "z": "a72683cc5cd6f15e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "options",
                "pt": "msg",
                "to": "[]",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 780,
        "y": 400,
        "wires": [
            [
                "31692e835acece2c"
            ]
        ]
    },
    {
        "id": "2be6d9a175c7b0e0",
        "type": "inject",
        "z": "a72683cc5cd6f15e",
        "name": "",
        "props": [],
        "repeat": "3600",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "x": 530,
        "y": 320,
        "wires": [
            [
                "9378e80cf1cb75de"
            ]
        ]
    },
    {
        "id": "51c36ff277bd9a6e",
        "type": "change",
        "z": "a72683cc5cd6f15e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "null",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 680,
        "y": 500,
        "wires": [
            [
                "31692e835acece2c"
            ]
        ]
    },
    {
        "id": "9378e80cf1cb75de",
        "type": "switch",
        "z": "a72683cc5cd6f15e",
        "name": "",
        "property": "KalanderDaten",
        "propertyType": "global",
        "rules": [
            {
                "t": "null"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 670,
        "y": 320,
        "wires": [
            [],
            [
                "48292bafe507e974"
            ]
        ]
    },
    {
        "id": "e2459ea6aab21c76",
        "type": "ui_group",
        "name": "Default",
        "tab": "5faeab580addd8f1",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "5faeab580addd8f1",
        "type": "ui_tab",
        "name": "Crash_test",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]
dceejay commented 1 year ago

Ah right - actually it is the topic being set to msg.payload.mitarbeiter - and then not existing on the input msg that is causing this...