onAirLightAction() errors out but light is on in the UI

Hi,

I noticed that the ON AIR light in the Libretime UI is inconsistent with the on-air-light API action under specific circumstances: when there is no show currently scheduled, but there is a source connected to the master stream (I didn’t try the show stream but I imagine the same thing would happen). When this happens, the ON AIR light is on in the UI, but the API call errors out. Here are the logs from the API container:

dev-legacy-1           | 2023-02-26T14:05:49+00:00 ERR (3): [ErrorController.php:28 - errorAction()] - Trying to access array offset on value of type null
dev-legacy-1           | 2023-02-26T14:05:49+00:00 ERR (3): [ErrorController.php:29 - errorAction()] - #0 /var/www/html/application/controllers/ApiController.php(212): exception_error_handler()
dev-legacy-1           | #1 /var/www/html/vendor/zf1s/zend-controller/library/Zend/Controller/Action.php(516): ApiController->onAirLightAction()
dev-legacy-1           | #2 /var/www/html/vendor/zf1s/zend-controller/library/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch()
dev-legacy-1           | #3 /var/www/html/vendor/zf1s/zend-controller/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch()
dev-legacy-1           | #4 /var/www/html/vendor/zf1s/zend-application/library/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
dev-legacy-1           | #5 /var/www/html/vendor/zf1s/zend-application/library/Zend/Application.php(391): Zend_Application_Bootstrap_Bootstrap->run()
dev-legacy-1           | #6 /var/www/html/application/airtime-boot.php(77): Zend_Application->run()
dev-legacy-1           | #7 /var/www/html/public/index.php(56): require_once('/var/www/html/a...')
dev-legacy-1           | #8 {main}
dev-legacy-1           | 2023-02-26T14:05:49+00:00 ERR (3): [ErrorController.php:62 - errorAction()] - An internal application error has occurred.: ErrorException: Trying to access array offset on value of type null in /var/www/html/application/controllers/ApiController.php:212
dev-legacy-1           | Stack trace:
dev-legacy-1           | #0 /var/www/html/application/controllers/ApiController.php(212): exception_error_handler()
dev-legacy-1           | #1 /var/www/html/vendor/zf1s/zend-controller/library/Zend/Controller/Action.php(516): ApiController->onAirLightAction()
dev-legacy-1           | #2 /var/www/html/vendor/zf1s/zend-controller/library/Zend/Controller/Dispatcher/Standard.php(308): Zend_Controller_Action->dispatch()
dev-legacy-1           | #3 /var/www/html/vendor/zf1s/zend-controller/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch()
dev-legacy-1           | #4 /var/www/html/vendor/zf1s/zend-application/library/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
dev-legacy-1           | #5 /var/www/html/vendor/zf1s/zend-application/library/Zend/Application.php(391): Zend_Application_Bootstrap_Bootstrap->run()
dev-legacy-1           | #6 /var/www/html/application/airtime-boot.php(77): Zend_Application->run()
dev-legacy-1           | #7 /var/www/html/public/index.php(56): require_once('/var/www/html/a...')
dev-legacy-1           | #8 {main}
dev-legacy-1           | 172.24.0.13 -  26/Feb/2023:14:05:49 +0000 "GET /index.php" 500

I looked into the code and this seems to be happening because range['tracks']['current'] is null here. That makes sense, because it’s basically the output of this query which is empty when there is no show currently scheduled.

I would expect the API action to behave the way the UI does: if something is streaming, the API call should return true, regardless of whether there is a show currently scheduled or not. Only looking at scheduled shows is opinionated and, I think, wrong.

So the question is: is there a way to get the API call to work, other than scheduling shows 24/7 in Libretime?

For context, we use the on-air-light call to power the on air light on our own website, and we only enable the player when our on air light is on. There are three use-cases in which we might stream without having a show:

  • We’re currently migrating to Libretime and we’d like to use it for streaming while temporarily still using another tool for the calendar.
  • Our calendar is far from full and it often happens that a DJ goes beyond their allotted time. In this case, the player would be disabled the minute the show ends in Libretime, even if the DJ is still streaming.
  • It also happens that our DJs connect for an impromptu stream, without having a show. In this case the player would never be enabled and the DJ would be very lonely indeed.

Cheers
Oliver

Hey, thanks for the detailed report!

I made a fix here fix(legacy): on air light fails when no shows are scheduled by jooola · Pull Request #2402 · libretime/libretime · GitHub

Tell me if it doesn’t work for you.

Wow amazing, thanks so much. I see the legacy image was built for the branch, is it publicly available?

I injected the file into the legacy container and it seems to work nicely :ok_hand:

Not yet, we don’t publish builds from pull requests. Once it’s on the main branch, yes.

But be careful, I’m doing large changes to the liquidsoap script, so the main branch could break unexpectedly.

I injected the file into the legacy container and it seems to work nicely :ok_hand:

Great!