text icon indicating copy to clipboard operation
text copied to clipboard

"Failed to open file" when opening from search results in iOS app

Open christianhubmann opened this issue 6 months ago • 1 comments

Describe the bug When searching for a text file in the iOS app, and then trying to open the text file, I receive a "Failed to open file" error message. It does work when I navigate to the file in the folder view and open it from there.

To Reproduce Steps to reproduce the behavior:

  1. Open the Nextcloud iOS app
  2. Search for a text file
  3. Open it

Expected behavior The file should be opened from the search result, just like when navigating to it.

Screenshots Here are 2 screenshots from my phone. Screenshot 1 Screenshot 2 Note the strange filename in the 2nd screenshot, not sure if this is normal.

Server details:

  • Nextcloud version: 31.0.4
  • PHP Version: 8.3.20
  • Database: PostgreSQL 16.8

Nextcloud is running in a docker container (image nextcloud:apache) behind an nginx reverse proxy.

Client details:

  • OS: iOS
  • Browser: Nextcloud App
  • Browser version: 6.6.4
  • Device: iPhone 14 Pro
Logs

Nextcloud log (data/nextcloud.log)

Here is the log entry of the error. What I find suspicious is that the complete url is appended to the path query param. Is that normal?

{
    "reqId": "phpCCsp3U7gHy7dHEwrU",
    "level": 3,
    "time": "2025-06-19T20:31:23+02:00",
    "remoteAddr": "10.129.255.6",
    "user": "christian",
    "app": "files",
    "method": "POST",
    "url": "/ocs/v2.php/apps/files/api/v1/directEditing/open?path=/https://nextcloud.mydomain.com/remote.php/dav/files/Christian/Kochen/Sushireis.txt&editorId=text",
    "message": "Exception when opening a file through direct editing",
    "userAgent": "Mozilla/5.0 (iOS) Nextcloud-iOS/6.6.4 AppleWebKit/605.1.15 Mobile/15E148",
    "version": "31.0.4.1",
    "exception": {
        "Exception": "OCP\\Files\\NotFoundException",
        "Message": "/christian/files/https:/nextcloud.mydomain.com/remote.php/dav/files/Christian/Kochen/Sushireis.txt",
        "Code": 0,
        "Trace": [
            {
                "file": "/var/www/html/lib/private/Files/Node/LazyFolder.php",
                "line": 138,
                "function": "get",
                "class": "OC\\Files\\Node\\Root",
                "type": "->",
                "args": [
                    "/christian/files/https:/nextcloud.mydomain.com/remote.php/dav/files/Christian/Kochen/Sushireis.txt"
                ]
            },
            {
                "file": "/var/www/html/lib/private/DirectEditing/Manager.php",
                "line": 123,
                "function": "get",
                "class": "OC\\Files\\Node\\LazyFolder",
                "type": "->",
                "args": [
                    "/https://nextcloud.mydomain.com/remote.php/dav/files/Christian/Kochen/Sushireis.txt"
                ]
            },
            {
                "file": "/var/www/html/apps/files/lib/Controller/DirectEditingController.php",
                "line": 106,
                "function": "open",
                "class": "OC\\DirectEditing\\Manager",
                "type": "->",
                "args": [
                    "/https://nextcloud.mydomain.com/remote.php/dav/files/Christian/Kochen/Sushireis.txt",
                    "text",
                    null
                ]
            },
            {
                "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
                "line": 200,
                "function": "open",
                "class": "OCA\\Files\\Controller\\DirectEditingController",
                "type": "->",
                "args": [
                    "/https://nextcloud.mydomain.com/remote.php/dav/files/Christian/Kochen/Sushireis.txt",
                    "text",
                    null
                ]
            },
            {
                "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
                "line": 114,
                "function": "executeController",
                "class": "OC\\AppFramework\\Http\\Dispatcher",
                "type": "->",
                "args": [
                    {
                        "__class__": "OCA\\Files\\Controller\\DirectEditingController"
                    },
                    "open"
                ]
            },
            {
                "file": "/var/www/html/lib/private/AppFramework/App.php",
                "line": 161,
                "function": "dispatch",
                "class": "OC\\AppFramework\\Http\\Dispatcher",
                "type": "->",
                "args": [
                    {
                        "__class__": "OCA\\Files\\Controller\\DirectEditingController"
                    },
                    "open"
                ]
            },
            {
                "file": "/var/www/html/lib/private/Route/Router.php",
                "line": 307,
                "function": "main",
                "class": "OC\\AppFramework\\App",
                "type": "::",
                "args": [
                    "OCA\\Files\\Controller\\DirectEditingController",
                    "open",
                    {
                        "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
                    },
                    {
                        "_route": "ocs.files.directediting.open"
                    }
                ]
            },
            {
                "file": "/var/www/html/ocs/v1.php",
                "line": 49,
                "function": "match",
                "class": "OC\\Route\\Router",
                "type": "->",
                "args": [
                    "/ocsapp/apps/files/api/v1/directEditing/open"
                ]
            },
            {
                "file": "/var/www/html/ocs/v2.php",
                "line": 7,
                "args": [
                    "/var/www/html/ocs/v1.php"
                ],
                "function": "require_once"
            }
        ],
        "File": "/var/www/html/lib/private/Files/Node/Root.php",
        "Line": 182,
        "message": "Exception when opening a file through direct editing",
        "exception": {},
        "CustomMessage": "Exception when opening a file through direct editing"
    }
}

christianhubmann avatar Jun 19 '25 18:06 christianhubmann

Something interesting I found out: When I log in with "christian" (first letter lower case), the problem disappears. When I log in again with "Christian" (first letter upper case), the problem reappears.

christianhubmann avatar Jun 19 '25 21:06 christianhubmann

The NotFoundException seems expected given the weird path coming in via the router. And given that the Text app doesn't have a search provider, I don't think it's the Text app itself causing this.

I suspect the issue is either in the iOS client itself or in Server search provider.

Server side I don't see any obvious recent potentially related changes, but there are quite a few in the relevant areas of code in the iOS client.

https://github.com/nextcloud/NextcloudKit/blob/f8df227dad809562214b478e46074cdd7c273f2e/Sources/NextcloudKit/NextcloudKit%2BNCText.swift#L112

Unfortunately I don't have an iOS device to test on.

The uid upper/lower case difference you mentioned in the follow-up is interesting. That's almost certainly a good clue here. That doesn't seem like it's being handled right...

EDIT: Do you have any similar behave when testing the same scenarios via the Web UI in a standard browser? (I.e. not using the iOS client nor direct edit mode)?

joshtrichards avatar Jun 29 '25 22:06 joshtrichards