IcingaHostForm: Fix crashing of form for invalid check command (#2941)

fixes #2854
This commit is contained in:
Eric Lippmann 2024-12-12 13:16:38 +01:00 committed by GitHub
commit 32a644fad8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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(