From 1d19d40f2ec416574f13a9e8c1caee820cbd18e5 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Tue, 10 Dec 2024 13:23:51 +0100 Subject: [PATCH] IcingaHostForm: Fix crashing of form for invalid check command --- application/forms/IcingaHostForm.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application/forms/IcingaHostForm.php b/application/forms/IcingaHostForm.php index d7bca9c31..b9c03ce94 100644 --- a/application/forms/IcingaHostForm.php +++ b/application/forms/IcingaHostForm.php @@ -2,6 +2,7 @@ namespace Icinga\Module\Director\Forms; +use Exception; use Icinga\Exception\AuthenticationException; use Icinga\Module\Director\Auth\Permission; use Icinga\Module\Director\Auth\Restriction; @@ -83,7 +84,13 @@ protected function addClusteringElements() 'class' => 'autosubmit', ]); - if ($this->getSentOrResolvedObjectValue('has_agent') === 'y') { + try { + $hasAgent = $this->getSentOrResolvedObjectValue('has_agent') === 'y'; + } catch (Exception $e) { + $hasAgent = false; + } + + if ($hasAgent) { $this->addBoolean('master_should_connect', [ 'label' => $this->translate('Establish connection'), 'description' => $this->translate(