Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(TaskProcessing): Catch JSON encode errors in Manager#setTaskResult
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr authored and AndyScherzinger committed Jan 24, 2025
commit 44aa380ce49f2be3f0806b6d2267f016feaacc2c
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 @@
$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 @@
$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
Loading