Skip to content
This repository has been archived by the owner on Sep 9, 2023. It is now read-only.

Undefined author object throws TypeError #3

Open
ferdinand opened this issue Aug 3, 2019 · 0 comments
Open

Undefined author object throws TypeError #3

ferdinand opened this issue Aug 3, 2019 · 0 comments

Comments

@ferdinand
Copy link

If the author object is not defined in the media.json file a TypeError is thrown.

[
  {
    "name": "Ukulele Song",
    "url": "https://freepd.com/music/Ukulele%20Song.mp3"
  }
]

The above JSON leads to the following error message:

[8/3/2019, 12:23:10 AM] TypeError: Cannot read property 'name' of undefined
    at AutomationChromecastPlay.playRandomMedia (/homebridge/node_modules/homebridge-automation-chromecast-play/index.js:116:44)
    at AutomationChromecastPlay.setSwitch (/homebridge/node_modules/homebridge-automation-chromecast-play/index.js:85:12)
    at Characteristic.On.emit (events.js:198:13)
    at Characteristic.On.Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:321:10)
    at Bridge.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:882:22)
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:822:8)
    at HAPServer.emit (events.js:198:13)
    at HAPServer._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:974:10)
    at HAPServer.<anonymous> (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39)

An empty author object works:

[
  {
    "name": "Ukulele Song",
    "url": "https://freepd.com/music/Ukulele%20Song.mp3",
    "author": {
    }
  }
]

As the author.name attribute is not required it shouldn't be required to define an (empty) author object.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant