node-red-contrib-huemagic: Uncaught Exception: Cannot read properties of undefined (reading 'length')
Describe the bug Updated NodeRED to 2.2.0 (NodeJS 16) today and no I constantly get Uncaught exception errors on starting up
Expected behavior No crash on startup
Log
TypeError: Cannot read properties of undefined (reading 'length') at new HueBridgeMessage (/data/node_modules/node-red-contrib-huemagic/huemagic/utils/messages.js:17:61) at HueBridge.get (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:306:23) at /data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge.js:84:30 at EventEmitter.<anonymous> (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:556:7) at EventEmitter.emit (node:events:390:28) at EventEmitter.emit (node:domain:475:12) at HueBridge.pushUpdatedState (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:275:16) at Timeout._onTimeout (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:177:13) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)
Please complete the following information:
- Node version: 4.1.0
- Node-RED version: 2.2.0
- NodeJS version: 16.13.1
- Device running Node-RED: Docker (20.10.12) on RaspberryPi 4B+ (4GB)
Additional context Problem occured after upgrade to Node-RED 2.2.0 but even reverting image back to 2.1.6 does not work. Before it worked with 4,1.0 on 2.1.6
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (3 by maintainers)
Hello,
not sure when Foddy will have time to investigate / fix this so maybe my temporary solution also helps you. I checked the API output manually via:
https://<bridge-ip>/api/<api-key>for the values ofstarterkitidandwhitelist. Then I checkedmessages.jsinhuemagic/utils/-folder and adjusted it manually here (in my case the string was empty so I just put= false;) and here (Just if you need the user listing function - otherwise leave it and just comment the for loop). Finally I commented this lines out (the whole For-loop). After that it is working for now for me. Hope this helps you for now too.Regards Jörg
Hi @unclej84 ,
wouldn’t it be better to change the respective lines like this:
and
@jeroenhendricksen please note that the migration to 4.X.X also requires some additional adjustment to the nodes as stated here because of the UUIDs in the API.
The responsible line in messages.js seems to be
this.message.payload.starterKitId = resource.starterkitid.length > 0 ? resource.starterkitid : false;. The api returns"starterkitid": "",in the config section of the json. I have then tried to set it to false by replacing the line withthis.message.payload.starterKitId = false;but got another error.TypeError: Cannot convert undefined or null to object at Function.entries (<anonymous>) at new HueBridgeMessage (/data/node_modules/node-red-contrib-huemagic/huemagic/utils/messages.js:45:39) at HueBridge.get (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:306:23) at /data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge.js:84:30 at EventEmitter.<anonymous> (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:556:7) at EventEmitter.emit (node:events:390:28) at EventEmitter.emit (node:domain:475:12) at HueBridge.pushUpdatedState (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:275:16) at Timeout._onTimeout (/data/node_modules/node-red-contrib-huemagic/huemagic/hue-bridge-config.js:177:13) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)Is seems that the lookup of
whitelistdoes also not work - the api returns this directly afterstarterkitid. These are the last two entries of the config section.The fields
touchlink,autoupdateandupdatedare not included in the config section. Api-Version is shown as1.48.0.If you need further information or details, please let me know.