AssignRenderer: show JSON parsing error source

refs #2667
This commit is contained in:
Thomas Gelf 2023-07-30 20:26:32 +02:00
parent 26a4a10536
commit 8e4ebb79d7
2 changed files with 10 additions and 2 deletions

View File

@ -16,6 +16,7 @@ This version hasn't been released yet
* FEATURE: Deployment Log now breaks lines (#2677)
* FEATURE: Sort Template trees by name (#2691)
* FEATURE: Branch and Sync diff/preview now shows related host for services (#2736)
* FEATURE: Show more details for assign filter parsing errors (#2667)
* FIX: do not fail for (some) Service Dependencies (#2669, #1142)
* FIX: Service Sets can now be searched by Service name in branches too (#2738)

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\IcingaConfig;
use gipfl\Json\JsonDecodeException;
use gipfl\Json\JsonString;
use Icinga\Data\Filter\Filter;
use Icinga\Data\Filter\FilterAnd;
@ -128,8 +129,14 @@ class AssignRenderer
}
$column = $filter->getColumn();
$rawExpression = Json::decode($filter->getExpression());
$expression = $this->renderExpressionValue($rawExpression);
try {
$rawExpression = JsonString::decode($filter->getExpression());
$expression = $this->renderExpressionValue($rawExpression);
} catch (JsonDecodeException $e) {
throw new InvalidArgumentException(
"Got invalid JSON in filter string: $column" . $filter->getSign() . $filter->getExpression()
);
}
if (is_array($rawExpression) && $filter instanceof FilterMatch) {
return $this->renderInArray($column, $expression);