502 Bad Gateway due to faulty flow - change json of flow

Node-Red plugin won’t run anymore. Appearantly it was possible to save a flow with a node that was missing a mandatory variable, which now causes Node Red to crash at boot according to the log. So I tried to modify flows.json to just remove that node. But flows.json in the add_ons directory get’s overwritten. I found that Node Red runs from a Docker container so it probably copies flows.json from the docker container to the HASSIO file system. Since the container stops running I don’t know how to access the file system in that container. Does anyone have an idea of how to do that?

Error from log:

3 Sep 21:22:54 - [red] Uncaught Exception:
3 Sep 21:22:54 - [error] TypeError: Cannot read properties of undefined (reading 'homeId')
    at TibberDataNode._inputCallback (/config/node_modules/node-red-contrib-tibber-api/nodes/tibber-data.js:23:82)
    at /opt/node_modules/@node-red/runtime/lib/nodes/Node.js:214:26
    at Object.trigger (/opt/node_modules/@node-red/util/lib/hooks.js:166:13)
    at TibberDataNode.Node._emitInput (/opt/node_modules/@node-red/runtime/lib/nodes/Node.js:206:11)
    at TibberDataNode.Node.emit (/opt/node_modules/@node-red/runtime/lib/nodes/Node.js:190:25)
    at TibberDataNode.Node.receive (/opt/node_modules/@node-red/runtime/lib/nodes/Node.js:499:10)
    at deliverMessageToDestination (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:803:40)
    at Immediate.<anonymous> (/opt/node_modules/@node-red/runtime/lib/flows/Flow.js:819:21)
    at processImmediate (node:internal/timers:476:21)

Boot into safe mode and you should be able to modify the nodes from there.

https://github.com/hassio-addons/addon-node-red/blob/f2130f0e9923455a83c533167e4f9a2a209d4f32/node-red/DOCS.md#option-safe_mode

1 Like

Thanks for your reply. Unfortunately that didn’t work, same error :frowning: I’m guessing even though it doesn’t run the flow NR crashes because the code it reads, even without executing, misses that variable :frowning:

Just to check your steps, on the configuration tab, you turn on the safe mode switch and then click save. Then a dialog box open asking to restart? In the log can you see the --safe flag?

1 Like

I got it working! I tried to toggle but I got an error so changed it in the yaml directly and saved that. But when I checked the log like you suggested I found that NR wasn’t started with the --safe argument. So I toggled in the UI again and solved the error (appearantly if you toggle safe mode one has to manually set the log level even though it was already logging).

Thanks, @Kermit too.