Skip to content

fix(TaskProcessing): Normalize file ID before getting node - #60218

Merged
marcelklehr merged 3 commits into
masterfrom
fix/tp-file-id
Nov 9, 2026
Merged

marcelklehr merged 3 commits into
masterfrom
fix/tp-file-id

Conversation

@marcelklehr

@marcelklehr marcelklehr commented May 7, 2026 •

Copy link
Copy Markdown
Member

Summary

getFirstNodeById will throw if it gets anything other than an int.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr marcelklehr added this to the Nextcloud 34 milestone May 7, 2026
@marcelklehr
marcelklehr requested a review from a team as a code owner May 7, 2026 12:51
@marcelklehr
marcelklehr requested review from ArtificialOwl and removed request for a team May 7, 2026 12:51
@marcelklehr marcelklehr added the 3. to review Waiting for reviews label May 7, 2026
Comment thread lib/private/TaskProcessing/Manager.php Resolved
@marcelklehr

Copy link
Copy Markdown
Member Author

/backport to stable32

@marcelklehr

Copy link
Copy Markdown
Member Author

/backport to stable33

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@max-win-at

Copy link
Copy Markdown

Independent confirmation on a current release, in case it helps this land.

Environment: Nextcloud 35.0.2 (build 35.0.2.2), docker.io/library/nextcloud:35-apache, PHP 8.5.12, task type core:image2text:ocr (input shape ListOfFiles), provider served by an external app through AppAPI.

Repro — form-encoded, which is how most scripts call OCS:

curl -u user:pass -H 'OCS-APIRequest: true' -X POST \
  --data-urlencode 'type=core:image2text:ocr' \
  --data-urlencode 'appId=my_exapp' \
  --data-urlencode 'input[input][0]=12345' \
  'https://cloud.example.com/ocs/v2.php/taskprocessing/schedule?format=json'

→ OCS 996 Internal Server Error, and in nextcloud.log:

OC\Files\Node\LazyFolder::getFirstNodeById(): Argument #1 ($id) must be of type int, string given,
called in /var/www/html/lib/private/TaskProcessing/Manager.php on line 1897

The same request with a JSON body succeeds:

-d '{"type":"core:image2text:ocr","appId":"my_exapp","input":{"input":[12345]}}'
-H 'Content-Type: application/json'

Why: validateInput() casts with (int) for its own check but does not rewrite the task input, so the later access check — foreach ($ids as $fileId) { $this->validateFileId($fileId); … } — hands the raw numeric string to the strictly-typed getFirstNodeById(int $id). The PR's normalisation in validateFileId() covers exactly this.

Not a regression, and not new in 35. I diffed lib/private/TaskProcessing/Manager.php between 34.0.5 and 35.0.2: validateFileId(), declare(strict_types=1) and the access-check loop are identical in both — only line numbers moved (34: 1594/1737 → 35: 1753/1896). So this has been reachable since at least 34.0.5, which makes it a long-standing API bug rather than something 35 introduced.

Until this lands, the workaround is to send JSON rather than form fields.

Comment thread lib/private/TaskProcessing/Manager.php Resolved
@marcelklehr
marcelklehr enabled auto-merge November 9, 2026 11:08
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr
marcelklehr merged commit 3f0e395 into master Nov 9, 2026
155 checks passed
@marcelklehr
marcelklehr deleted the fix/tp-file-id branch November 9, 2026 11:29
@marcelklehr

Copy link
Copy Markdown
Member Author

/backport to stable34

@marcelklehr

Copy link
Copy Markdown
Member Author

/backport to stable35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants