Skip to content

Store taskprocessing output files with extension to ease mimtype guessing - #61689

Merged
nickvergessen merged 15 commits into
masterfrom
feat/taskprocessing-output-files-with-mimetypes
Jul 21, 2026
Merged

Store taskprocessing output files with extension to ease mimtype guessing#61689
nickvergessen merged 15 commits into
masterfrom
feat/taskprocessing-output-files-with-mimetypes

Conversation

@marcelklehr

@marcelklehrmarcelklehr commented Jul 1, 2026

Copy link
Copy Markdown
Member

Summary

Currently, we have to guess the mime type entirely from the data which is sometimes hard. With this we allow synchronous providers to hint the file extension and mime type.

Also adds some needed attributes.

TODO

  • How should we allow ex apps to pass this information?

Checklist

AI (if applicable)

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

@marcelklehrmarcelklehr added this to the Nextcloud 35 milestone Jul 1, 2026
@marcelklehr
marcelklehr requested a review from a team as a code ownerJuly 1, 2026 11:29
@marcelklehr
marcelklehr requested review from Altahrim and salmart-dev and removed request for a teamJuly 1, 2026 11:29
@marcelklehrmarcelklehr added the 2. developing Work in progress label Jul 1, 2026
Comment threadlib/public/TaskProcessing/EShapeType.php Outdated
@marcelklehr
marcelklehrforce-pushed the feat/taskprocessing-output-files-with-mimetypes branch from a499488 to 944e422CompareJuly 1, 2026 12:07
@marcelklehrmarcelklehr added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jul 1, 2026

@julien-ncjulien-nc left a comment

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.

Lgtm 👍

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the TaskProcessing public API and implementation to better handle “file-shaped” task outputs by allowing providers (and ExApps uploads) to influence stored output filenames via extensions, with the goal of improving MIME type detection downstream. It also annotates several public TaskProcessing interfaces/data objects with #[Implementable] / #[Consumable] attributes.

Changes:

  • Introduces OCP\TaskProcessing\FileShaped and updates synchronous provider return type annotations to allow returning FileShaped values.
  • Extends output validation (EShapeType::validateOutputWithFileData) and output encapsulation (Manager::encapsulateOutputFileData) to accept file-shaped outputs.
  • Appends file extensions when storing uploaded/provider output data in AppData, and adds Implementable/Consumable attributes to several public APIs.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 14 comments.

Show a summary per file
FileDescription
lib/public/TaskProcessing/SynchronousProviderOptions.phpMarks the options class as #[Consumable] for public API consumption.
lib/public/TaskProcessing/ShapeEnumValue.phpMarks the DTO as #[Consumable].
lib/public/TaskProcessing/ShapeDescriptor.phpMarks the DTO as #[Consumable].
lib/public/TaskProcessing/ITriggerableProvider.phpMarks provider interface as #[Implementable] (but since metadata needs correction).
lib/public/TaskProcessing/ITaskType.phpMarks task type interface as #[Implementable].
lib/public/TaskProcessing/ISynchronousProvider.phpMarks interface as #[Implementable] and expands psalm return types to include FileShaped.
lib/public/TaskProcessing/ISynchronousOptionsAwareProvider.phpMarks interface as #[Implementable] and expands psalm return types to include FileShaped.
lib/public/TaskProcessing/IProvider.phpMarks provider interface as #[Implementable].
lib/public/TaskProcessing/IInternalTaskType.phpMarks internal task type interface as #[Implementable] (minor formatting consistency).
lib/public/TaskProcessing/FileShaped.phpAdds new public DTO to carry file-shaped output data + metadata (extension/mime type).
lib/public/TaskProcessing/EShapeType.phpUpdates output validation to allow FileShaped (but list validation currently has critical logic errors).
lib/private/TaskProcessing/Manager.phpStores file outputs using provided extensions (but list branch currently clears unrelated output keys and needs extension normalization).
core/Controller/TaskProcessingApiController.phpAppends extension when storing ExApp uploaded files (needs extension sanitization/normalization).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadlib/public/TaskProcessing/EShapeType.php Outdated
Comment threadlib/public/TaskProcessing/EShapeType.php Outdated
Comment threadlib/public/TaskProcessing/EShapeType.php Outdated
Comment threadlib/public/TaskProcessing/EShapeType.php Outdated
Comment threadlib/private/TaskProcessing/Manager.php
Comment threadlib/public/TaskProcessing/FileShaped.php
Comment threadlib/public/TaskProcessing/FileShaped.php Outdated
Comment threadlib/public/TaskProcessing/FileShaped.php Outdated
Comment threadlib/public/TaskProcessing/FileShaped.php Outdated
Comment threadlib/private/TaskProcessing/Manager.php
marcelklehrand others added 10 commits July 14, 2026 12:25
…ype guessing
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
…erty
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Assisted-by: ClaudeCode:claude-opus-4-8
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr
marcelklehrforce-pushed the feat/taskprocessing-output-files-with-mimetypes branch from 8d2c8e2 to 70e7feaCompareJuly 14, 2026 10:26

@julien-ncjulien-nc left a comment

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.

Lgtm. A few nitpicks.

Comment threadlib/public/TaskProcessing/FileShaped.php Outdated
Comment threadlib/public/TaskProcessing/FileShaped.php Outdated
Comment threadlib/public/TaskProcessing/FileShaped.php
Comment threadlib/public/TaskProcessing/FileShaped.php Outdated
Comment threadcore/Controller/TaskProcessingApiController.php Outdated
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr
marcelklehrforce-pushed the feat/taskprocessing-output-files-with-mimetypes branch from 3c6bd44 to 326b94aCompareJuly 15, 2026 05:50
Comment threadcore/Controller/TaskProcessingApiController.php Outdated
Comment threadlib/public/TaskProcessing/EShapeType.php
Comment threadlib/public/TaskProcessing/EShapeType.php Outdated
Comment threadlib/public/TaskProcessing/ISynchronousProvider.php
Comment threadlib/public/TaskProcessing/FileShaped.php
Signed-off-by: Marcel Klehr <mklehr@gmx.net>

@lukasdotcomlukasdotcom left a comment

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.

Something small I noticed while skimming.

Comment threadlib/public/TaskProcessing/FileShaped.php
@kyteinsky

Copy link
Copy Markdown
Contributor

lgtm apart from Lukas' review ✅

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

@lukasdotcomlukasdotcom left a comment

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'd still swap the order of the denylist incase there is some random character that can be put into the extension and that is then filtered out on line 64. Otherwise looks good.

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
@marcelklehr

Copy link
Copy Markdown
MemberAuthor

incase there is some random character that can be put into the extension and that is then filtered out on line 64

Ah, yes. that would be a mean attack indeed. Changed it :)

@nickvergessen
nickvergessen merged commit cb249a4 into masterJul 21, 2026
242 of 246 checks passed
@nickvergessen
nickvergessen deleted the feat/taskprocessing-output-files-with-mimetypes branch July 21, 2026 07:58
@nextcloud-botnextcloud-bot mentioned this pull request Aug 11, 2026
Sign up for freeto 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

@marcelklehr@kyteinsky@miaulalala@julien-nc@lukasdotcom@nickvergessen@nextcloud-command