aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/Migrations/Version30000Date20240906095113.php40
-rw-r--r--lib/private/TaskProcessing/Manager.php5
2 files changed, 43 insertions, 2 deletions
diff --git a/core/Migrations/Version30000Date20240906095113.php b/core/Migrations/Version30000Date20240906095113.php
new file mode 100644
index 00000000000..4991aecb078
--- /dev/null
+++ b/core/Migrations/Version30000Date20240906095113.php
@@ -0,0 +1,40 @@
+<?php
+
+declare(strict_types=1);
+
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OC\Core\Migrations;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\Attributes\ModifyColumn;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+#[ModifyColumn(table: 'taskprocessing_tasks', name: 'error_message', description: 'Increase column length to 4000 bytes to support longer error messages')]
+class Version30000Date20240906095113 extends SimpleMigrationStep {
+
+ /**
+ * @param IOutput $output
+ * @param Closure(): ISchemaWrapper $schemaClosure
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $table = $schema->getTable('taskprocessing_tasks');
+ $column = $table->getColumn('error_message');
+
+ if ($column->getLength() < 4000) {
+ $column->setLength(4000);
+ }
+
+ return $schema;
+ }
+}
diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php
index 1b170a03ec2..29153ca56f9 100644
--- a/lib/private/TaskProcessing/Manager.php
+++ b/lib/private/TaskProcessing/Manager.php
@@ -891,7 +891,8 @@ class Manager implements IManager {
if ($error !== null) {
$task->setStatus(Task::STATUS_FAILED);
$task->setEndedAt(time());
- $task->setErrorMessage($error);
+ // truncate error message to 1000 characters
+ $task->setErrorMessage(mb_substr($error, 0, 1000));
$this->logger->warning('A TaskProcessing ' . $task->getTaskTypeId() . ' task with id ' . $id . ' failed with the following message: ' . $error);
} elseif ($result !== null) {
$taskTypes = $this->getAvailableTaskTypes();
@@ -956,7 +957,7 @@ class Manager implements IManager {
$this->taskMapper->update($taskEntity);
$this->runWebhook($task);
} catch (\OCP\DB\Exception $e) {
- throw new \OCP\TaskProcessing\Exception\Exception('There was a problem finding the task', 0, $e);
+ throw new \OCP\TaskProcessing\Exception\Exception($e->getMessage());
}
if ($task->getStatus() === Task::STATUS_SUCCESSFUL) {
$event = new TaskSuccessfulEvent($task);