From ee31b3bbe525d1499d7e64962fd0d3521e23a358 Mon Sep 17 00:00:00 2001 From: Jana Peper Date: Tue, 17 Dec 2024 17:00:07 +0100 Subject: fix: error handling for wrong json values Signed-off-by: Jana Peper --- lib/private/TaskProcessing/Manager.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index 8afc62a05d4..96cdc8c44f8 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -568,11 +568,23 @@ class Manager implements IManager { * @return array */ private function _getTaskTypeSettings(): array { - $json = $this->config->getAppValue('core', 'ai.taskprocessing_type_preferences', ''); - if ($json === '') { - return []; + try { + $json = $this->config->getAppValue('core', 'ai.taskprocessing_type_preferences', ''); + if ($json === '') { + return []; + } + return json_decode($json, true, flags: JSON_THROW_ON_ERROR); + } catch (\JsonException $e) { + $this->logger->error('Failed to get settings. JSON Error in ai.taskprocessing_type_preferences', ['exception' => $e]); + $taskTypeSettings = []; + $taskTypes = $this->_getTaskTypes(); + foreach ($taskTypes as $taskType) { + $taskTypeSettings[$taskType->getId()] = false; + }; + + return $taskTypeSettings; } - return json_decode($json, true, flags: JSON_THROW_ON_ERROR); + } /** -- cgit v1.2.3