diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index 4dd4fc36a245a..82fe422aab127 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -1633,9 +1633,16 @@ private function validateOutputFileIds(array $output, ...$specs): array { * @throws ValidationException */ private function validateFileId(mixed $id): File { - $node = $this->rootFolder->getFirstNodeById($id); + if (is_int($fileId)) { + $normalizedFileId = $fileId; + } elseif (is_string($fileId) && ctype_digit($fileId)) { + $normalizedFileId = (int)$fileId; + } else { + throw new \InvalidArgumentException('File ID must be an integer: ' . $id); + } + $node = $this->rootFolder->getFirstNodeById($normalizedFileId); if ($node === null) { - $node = $this->rootFolder->getFirstNodeByIdInPath($id, '/' . $this->rootFolder->getAppDataDirectoryName() . '/'); + $node = $this->rootFolder->getFirstNodeByIdInPath($normalizedFileId, '/' . $this->rootFolder->getAppDataDirectoryName() . '/'); if ($node === null) { throw new ValidationException('Could not find file ' . $id); } elseif (!$node instanceof File) {