Skip to content

fix(TaskProcessing): resolve task file ids in the task user's files, not the root folder - #67073

Open
julien-nc wants to merge 1 commit into
masterfrom
fix/taskprocessing-scope-file-lookup-to-task-user
Open

julien-nc wants to merge 1 commit into
masterfrom
fix/taskprocessing-scope-file-lookup-to-task-user

Conversation

@julien-nc

@julien-nc julien-nc commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Summary

TaskProcessingApiController::getFileContentsInternal() resolved a task's file id with IRootFolder::getFirstNodeById(), which is not scoped to a user. Through the per-user path cache or the first-mount fallback of Root::getByIdInPath(), that lookup can return the node in another user's home, so a task kept serving its input file after the task's user had lost access to it.

The lookup now goes through getUserFolder($task->getUserId())->getFirstNodeById(), so only what the task's user can reach right now is found. Output files in app data are still served by the existing fallback lookup, also when the task has no user or its user is gone (NoUserException is caught).

The helper is shared by the user route (tasks/{taskId}/file/{fileId}) and the ExApp route (tasks_provider/{taskId}/file/{fileId}), so both are covered.

Behavior change

An input file that the task's own user moved to the trash bin is no longer served (404 instead of 200), consistent with the synchronous provider path, where Manager::fillInputFileData() re-checks access before reading the input.

Testing

  • New tests/Core/Controller/TaskProcessingApiControllerTest.php (7 tests): file in the task user's folder, file the user has no access to (404), output file in app data for both routes, and the deleted-user case on the ExApp route. All tests fail before this change and pass after it.
  • Validated on a live instance: a file still shared with the task's user and the user's own files are served as before; after removing the share the endpoint answers 404.

Assisted by OpenCode:glm-5.3-flash

Checklist

AI (if applicable)

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

…not the root folder

getFileContentsInternal() resolved a task's file id with
IRootFolder::getFirstNodeById(), which is not scoped to a user. Through
the per-user path cache or the first-mount fallback of
Root::getByIdInPath() it can return the node in another user's home, so
a task kept serving its input file after the user's access to it was
removed. The lookup now goes through getUserFolder($task->getUserId()),
so only what the task's user can reach right now is found. Output
files in app data are still served by the existing fallback lookup,
also when the task has no user or its user is gone.

The helper is shared by the user route (tasks/{taskId}/file/{fileId})
and the ExApp route (tasks_provider/{taskId}/file/{fileId}), so both
are covered. Manager::validateFileId() keeps its root lookup because
its callers for input files call validateUserAccessToFile() on the
same id.

An input file that the task's own user moved to the trash bin is no
longer served (404), consistent with the synchronous provider path.

Assisted-by: OpenCode:glm-5.3-flash
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
@julien-nc julien-nc added this to the Nextcloud 36 milestone Nov 27, 2026
@julien-nc
julien-nc requested a review from a team as a code owner November 27, 2026 11:19
@julien-nc julien-nc added the bug label Nov 27, 2026
@julien-nc
julien-nc requested review from Altahrim and salmart-dev and removed request for a team November 27, 2026 11:19
@julien-nc

Copy link
Copy Markdown
Member Author

/backport to stable35

@julien-nc

Copy link
Copy Markdown
Member Author

/backport to stable34

@julien-nc

Copy link
Copy Markdown
Member Author

/backport to stable33

This branch has not been deployed

No deployments
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.

3 participants