[Bug]: Preview HTTP 500 for file-level Federated Shares - preview runs in context of federated user (NoUserException)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
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
- Server A (NC 33): User
user1@remote-servershares a single file (e.g.cleo.jpg) as a Federated Share torecipient@your-server -
- Recipient accepts the share on Server B (NC 33)
-
- Recipient opens the "Shared with me" view
-
- Browser requests
/core/preview?fileId=<id>&x=32&y=32&mimeFallback=true→ HTTP 500
- Browser requests
-
- 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
- Apps:
-
-
-
-
-
-
-
-
- Both servers mutual trusted: yes (status=1 in
oc_trusted_serverson both sides)
- Both servers mutual trusted: yes (status=1 in
-
-
-
-
Related
- Similar symptom (different cause): #58787 (preview cache file missing)
-
- Federated share empty folder: #46025
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /core/preview endpoint and trace how file-level federated-share entries with empty path and name determine the user context. Inspect the handling around NoUserException and compare it with folder-level share entries in oc_filecache. Done means a preview request for a single federated file returns successfully for the local recipient without resolving the remote federated user as a local user.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100