Skip to content

Attaching a file to a federated share should be blocked. #7092

Description

@max-nextcloud

Describe the bug
Currently it's not possible to attach a file to a federated share of a markdown file.

We should disable the corresponding buttons in the ui and add a tooltip explaining why no files can be attached.

On the server side attempting to attach a file throws 'File has no owner' in the getAttachmentDirectoryForFile function.

To Reproduce
Steps to reproduce the behavior:

  1. Share a file with another nextcloud instance via federation.
  2. Open that file on the other instance.
  3. Try to add an attachment to it.

Expected behavior
The button should be disabled and a tooltip should explain why.

Screenshots
Will be added later.

Server details:

  • Nextcloud version: 28
Logs

Nextcloud log (data/nextcloud.log)

{
  "url": "/apps/text/attachment/upload?documentId=",
  "exception": {
    "Exception": "OCP\\Files\\NotFoundException",
    "Message": "File has no owner",
    "Code": 0,
    "Trace": [
      {
        "file": "/opt/nextcloud/apps/text/lib/Service/AttachmentService.php",
        "line": 287,
        "function": "getAttachmentDirectoryForFile",
        "class": "OCA\\Text\\Service\\AttachmentService",
        "type": "->"
      },
      {
        "file": "/opt/nextcloud/apps/text/lib/Controller/AttachmentController.php",
        "line": 144,
        "function": "uploadAttachment",
        "class": "OCA\\Text\\Service\\AttachmentService",
        "type": "->"
      },
      {
        "file": "/opt/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 230,
        "function": "uploadAttachment",
        "class": "OCA\\Text\\Controller\\AttachmentController",
        "type": "->"
      },
      {
        "file": "/opt/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 137,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/opt/nextcloud/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->"
      },
      {
        "file": "/opt/nextcloud/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::"
      },
      {
        "file": "/opt/nextcloud/lib/base.php",
        "line": 1069,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->"
      },
      {
        "file": "/opt/nextcloud/index.php",
        "line": 39,
        "function": "handleRequest",
        "class": "OC",
        "type": "::"
      }
    ],
    "File": "/opt/nextcloud/apps/text/lib/Service/AttachmentService.php",
    "Line": 436,
    "message": "Upload error",
    "exception": {},
    "CustomMessage": "Upload error"
  }
}

Activity

  1. moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity teamon Apr 9, 2025
  2. max-nextcloud commented on Apr 9, 2025

    @max-nextcloud
    CollaboratorAuthor

    How can the frontend know a text file is a federated share?

    The text js will need to know the file was federated.

    🔴 Option 1 - get info from the viewer

    The viewer fetches the fileinfo with a PROPFIND request. That PROPFIND includes the owner id and display name. Since the owner is not set for a federated share I expect this to show in the PROPFIND response - however the fileinfo is currently not exposed by the viewer. I suspect this is a bug as OCA.Viewer has a fileInfo property - but it remains null on our instance.
    However there are other downsides to relying on the Viewer. Namely the info won't be available in other places such as Collectives and folder descriptions.

    🟢 Option 2 - add info in the create API request

    It should be possible to check file.getOwner during the creation of the text session and provide the information in the response to the create request. Somewhere here: https://github.com/nextcloud/text/blob/main/lib/Service/ApiService.php#L150 - similar to the way the lock info is added.
    This seems to be the most flexible solution and it does not rely on other apps. So I propose to go with this one.

  3. moved this from 🧭 Planning evaluation (don't pick) to 🏗️ In progress in 📝 Productivity teamon Apr 28, 2025
  4. moved this from 🏗️ In progress to ☑️ Done in 📝 Productivity teamon May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions