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 <mklehr@gmx.net>
  • Loading branch information
marcelklehr authored and AndyScherzinger committed Jan 24, 2025
1 parent 30a4f92 commit 44aa380
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 @@ -973,7 +973,7 @@ public function setTaskResult(int $id, ?string $error, ?array $result, bool $isU
$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';
$task->setErrorMessage($error);
$this->logger->error($error, ['exception' => $e]);
$this->logger->error($error . ' Output was: ' . var_export($result, true), ['exception' => $e]);

Check failure on line 976 in lib/private/TaskProcessing/Manager.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHtml

lib/private/TaskProcessing/Manager.php:976:64: TaintedHtml: Detected tainted HTML (see https://psalm.dev/245)
} catch (NotPermittedException $e) {
$task->setProgress(1);
$task->setStatus(Task::STATUS_FAILED);
Expand All @@ -990,7 +990,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 44aa380

Please sign in to comment.