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

**URL:** <https://discourse.libretime.org/t/onairlightaction-errors-out-but-light-is-on-in-the-ui/1421>\
**Category:** Get Help\
**Created:** [February 26, 2023, 2:24pm UTC](https://discourse.libretime.org/t/onairlightaction-errors-out-but-light-is-on-in-the-ui/1421 "2023-02-26T14:24:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![olivermeyer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/olivermeyer/32/664_2.png) [@olivermeyer](https://discourse.libretime.org/u/olivermeyer)\
**Post date:** [February 26, 2023, 2:24pm UTC](https://discourse.libretime.org/t/onairlightaction-errors-out-but-light-is-on-in-the-ui/1421/1 "2023-02-26T14:24:14Z")

</div>

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:

```auto
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](https://github.com/libretime/libretime/blob/719d7cff3662f57064647cc9d6a9f143615b4e04/legacy/application/controllers/ApiController.php#L212https://github.com/libretime/libretime/blob/719d7cff3662f57064647cc9d6a9f143615b4e04/legacy/application/controllers/ApiController.php#L212). That makes sense, because it’s basically the output of [this query](https://github.com/libretime/libretime/blob/719d7cff3662f57064647cc9d6a9f143615b4e04/legacy/application/models/Schedule.php#L191) 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

---

<div class="post-metadata">

**Author:** ![joola](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@joola](https://discourse.libretime.org/u/joola)\
**Post date:** [February 26, 2023, 3:31pm UTC](https://discourse.libretime.org/t/onairlightaction-errors-out-but-light-is-on-in-the-ui/1421/2 "2023-02-26T15:31:44Z")

</div>

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](https://github.com/libretime/libretime/pull/2402)

Tell me if it doesn’t work for you.

---

<div class="post-metadata">

**Author:** ![olivermeyer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/olivermeyer/32/664_2.png) [@olivermeyer](https://discourse.libretime.org/u/olivermeyer)\
**Post date:** [February 26, 2023, 3:57pm UTC](https://discourse.libretime.org/t/onairlightaction-errors-out-but-light-is-on-in-the-ui/1421/3 "2023-02-26T15:57:12Z")

</div>

Wow amazing, thanks so much. I see the legacy image [was built](https://github.com/libretime/libretime/actions/runs/4275692243/jobs/7443231669) for the branch, is it publicly available?

---

<div class="post-metadata">

**Author:** ![olivermeyer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/olivermeyer/32/664_2.png) [@olivermeyer](https://discourse.libretime.org/u/olivermeyer)\
**Post date:** [February 26, 2023, 4:02pm UTC](https://discourse.libretime.org/t/onairlightaction-errors-out-but-light-is-on-in-the-ui/1421/4 "2023-02-26T16:02:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![joola](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@joola](https://discourse.libretime.org/u/joola)\
**Post date:** [February 26, 2023, 4:41pm UTC](https://discourse.libretime.org/t/onairlightaction-errors-out-but-light-is-on-in-the-ui/1421/5 "2023-02-26T16:41:15Z")

</div>

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 👌

Great!
