Skip to content

Commit 44aa380

Browse files
marcelklehrAndyScherzinger
authored andcommitted
fix(TaskProcessing): Catch JSON encode errors in Manager#setTaskResult
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 30a4f92 commit 44aa380

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/private/TaskProcessing/Manager.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
973973
$task->setEndedAt(time());
974974
$error = 'The task was processed successfully but the provider\'s output doesn\'t pass validation against the task type\'s outputShape spec and/or the provider\'s own optionalOutputShape spec';
975975
$task->setErrorMessage($error);
976-
$this->logger->error($error, ['exception' => $e]);
976+
$this->logger->error($error . ' Output was: ' . var_export($result, true), ['exception' => $e]);
977977
} catch (NotPermittedException $e) {
978978
$task->setProgress(1);
979979
$task->setStatus(Task::STATUS_FAILED);
@@ -990,7 +990,11 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
990990
$this->logger->error($error, ['exception' => $e]);
991991
}
992992
}
993-
$taskEntity = \OC\TaskProcessing\Db\Task::fromPublicTask($task);
993+
try {
994+
$taskEntity = \OC\TaskProcessing\Db\Task::fromPublicTask($task);
995+
} catch (\JsonException $e) {
996+
throw new \OCP\TaskProcessing\Exception\Exception('The task was processed successfully but the provider\'s output could not be encoded as JSON for the database.', 0, $e);
997+
}
994998
try {
995999
$this->taskMapper->update($taskEntity);
9961000
$this->runWebhook($task);

0 commit comments

Comments
 (0)