Skip to content

Commit

Permalink
fix(TaskProcessing): Catch JSON encode errors in Manager#setTaskResult
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jul 26, 2024
1 parent 87dc061 commit 99b59da
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
$task->setProgress(1);
$task->setStatus(Task::STATUS_FAILED);
$task->setEndedAt(time());
$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';
$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. Output was: ' . var_export($result, true);

Check failure

Code scanning / Psalm

TaintedHtml Error

Detected tainted HTML
$task->setErrorMessage($error);
$this->logger->error($error, ['exception' => $e]);
} catch (NotPermittedException $e) {
Expand All @@ -882,7 +882,11 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
$this->logger->error($error, ['exception' => $e]);
}
}
$taskEntity = \OC\TaskProcessing\Db\Task::fromPublicTask($task);
try {
$taskEntity = \OC\TaskProcessing\Db\Task::fromPublicTask($task);
} catch (\JsonException $e) {
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);
}
try {
$this->taskMapper->update($taskEntity);
$this->runWebhook($task);
Expand Down

0 comments on commit 99b59da

Please sign in to comment.