IcingaHostForm: Fix crashing of form for invalid check command

This commit is contained in:
raviks789 2024-12-10 13:23:51 +01:00 committed by Eric Lippmann
parent e37f802cf9
commit 8161a769fe

View File

@ -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 @@ class IcingaHostForm extends DirectorObjectForm
'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(