Skip to content

[Bug]: Preview HTTP 500 for file-level Federated Shares - preview runs in context of federated user (NoUserException) #60917

@EsherionM

Description

@EsherionM

Bug description

When a remote Nextcloud user shares a single file (not a folder) via Federated Share (OCM), the recipient's preview system returns HTTP 500 for all preview requests (/core/preview?fileId=...).

The root cause is that NC's preview system runs in the context of the federated share owner (user@remote-server) instead of the local recipient. Since the federated user does not exist as a local user, OC\User\NoUserException is thrown and the preview fails.

This only affects file-level federated shares. Folder-level federated shares work correctly because the files inside have proper path and name values in oc_filecache. File-level shares have path="" and name="" (the storage root represents the file itself), which causes the preview system to use the wrong user context.

Steps to reproduce

  1. Server A (NC 33): User user1@remote-server shares a single file (e.g. cleo.jpg) as a Federated Share to recipient@your-server
    1. Recipient accepts the share on Server B (NC 33)
    1. Recipient opens the "Shared with me" view
    1. Browser requests /core/preview?fileId=<id>&x=32&y=32&mimeFallback=trueHTTP 500
    1. Image viewer shows nothing / blank

Expected behavior

Preview thumbnail is generated and image displays in the viewer, just as it does for locally stored files or folder-level federated shares.

Actual behavior

/core/preview returns HTTP 500. The NC log shows:

[files] Backends provided no user object for buser1@remote-server
[index] Backends provided no user object

These errors appear exactly during the preview requests (verified via Apache access log correlation).

Root cause

For file-level federated shares, oc_filecache stores the file as the storage root:

Field File-level share Folder-level share
path "" (empty) "cleo.jpg"
name "" (empty) "cleo.jpg"

When the preview system processes a file with path="", it apparently resolves the user context as the federated share owner (user@remote-server) instead of the local authenticated user. Since the federated user has no local user object, the preview generation fails with NoUserException.

WebDAV access works fine: GET https://remote-server/public.php/webdav/ with the share token returns the correct file (HTTP 200, valid JPEG). The issue is exclusively in the preview system's user context handling.

Workaround

Have the remote user share a folder (not individual files). Files inside a folder share have proper path/name values and previews work correctly.

Environment

  • Nextcloud Server version: 33.0.3.2
    • Both servers: NC 33.0.3.2 (same version)
      • PHP: 8.3 (Server B), 8.4 (Server A)
        • OS: Debian (Server B: LXC container), Debian Trixie (Server A: Raspberry Pi)
          • Apps: federatedfilesharing: 1.23.0, cloud_federation_api: 1.17.0, federation_use_trusted_domains: yes
            • Both servers mutual trusted: yes (status=1 in oc_trusted_servers on both sides)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions