Skip to content
Open
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
11 changes: 9 additions & 2 deletions lib/private/TaskProcessing/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1633,9 +1633,16 @@
* @throws ValidationException
*/
private function validateFileId(mixed $id): File {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only pass int to this function and fix the string wherever it is coming from 🙈

Copy link
Copy Markdown
Member Author

@marcelklehr marcelklehr May 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please reconsider how task processing works before jumping to conclusions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $id param value originally comes from the task input which can be invalid. We don't know what the API consumer will have set in there. This seems justified to validate this like that.

Or maybe you meant something different.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just suggesting that this kind of validation should probably happen much earlier.

Anyway I'm fine with this, it was only a suggestion and therefore I didn't request changes.

$node = $this->rootFolder->getFirstNodeById($id);
if (is_int($fileId)) {

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

View workflow job for this annotation

GitHub Actions / static-code-analysis

UndefinedVariable

lib/private/TaskProcessing/Manager.php:1636:14: UndefinedVariable: Cannot find referenced variable $fileId (see https://psalm.dev/024)
$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) {
Expand Down
Loading