konnected-io / konnected-security

Konnected connects wired sensors and switches to SmartThings, Home Assistant, Hubitat and OpenHAB
https://konnected.io
Apache License 2.0
416 stars 322 forks source link

Unprotected crash/panic when REST endpoint responds with 401 #175

Closed heythisisnate closed 1 year ago

heythisisnate commented 1 year ago

Crashes on this line when the HTTP call on the lines above result in a 401 Unauthorized response: https://github.com/konnected-io/konnected-security/blob/a9a4ab473161e3c7a981eb8a2b9176d611df5052/src/lfs/rest_endpoint.lua#L57

bad argument #1 to 'mode' (number expected, got nil)
stack traceback:
    [C]: in function 'mode'
    ...ecurity/konnected-security/src/lfs/rest_endpoint.lua: in function <...ecurity/konnected-security/src/lfs/rest_endpoint.lua:38>

Local variable pin should be initialized by actuator.pin in the case when the initial HTTP GET for status fails. Manifested by this HomeBridge issue: https://github.com/konnected-io/homebridge-konnected/issues/8