diff options
author | Jana Peper <jana.peper@nextcloud.com> | 2024-12-17 17:00:07 +0100 |
---|---|---|
committer | janepie <49834966+janepie@users.noreply.github.com> | 2024-12-18 18:32:34 +0100 |
commit | ee31b3bbe525d1499d7e64962fd0d3521e23a358 (patch) | |
tree | 0c9c576d043f97402fef8cb5c34bcb283f994631 /lib | |
parent | d87302c651dfb18d80856c07d7a16e9c97d68bb0 (diff) | |
download | nextcloud-server-ee31b3bbe525d1499d7e64962fd0d3521e23a358.tar.gz nextcloud-server-ee31b3bbe525d1499d7e64962fd0d3521e23a358.zip |
fix: error handling for wrong json values
Signed-off-by: Jana Peper <jana.peper@nextcloud.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/TaskProcessing/Manager.php | 20 |
1 files changed, 16 insertions, 4 deletions
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); + } /** |