Skip to content

[Bug]: Weird state in appdata, incorrect return type handling #41645

@kesselb

Description

@kesselb

⚠️ This issue respects the following points: ⚠️

Bug description

Likely related to: #38761

After running tests locally, I end up with a wiped appdata from time to time.

Visiting the app store greets me with a friendly:

Screenshot from 2023-11-21 17-28-29

{
  "reqId": "YvlS81wDtRf9uV5nQ1v5",
  "level": 3,
  "time": "2023-11-21T16:27:23+00:00",
  "remoteAddr": "172.19.0.1",
  "user": "admin",
  "app": "index",
  "method": "GET",
  "url": "/index.php/settings/apps",
  "message": "Exception thrown: OCP\\Files\\GenericFileException",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36",
  "version": "28.0.0.6",
  "exception": {
    "Exception": "OCP\\Files\\GenericFileException",
    "Message": "",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/lib/private/Files/SimpleFS/SimpleFile.php",
        "line": 74,
        "function": "getContent",
        "class": "OC\\Files\\Node\\File",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/App/AppStore/Fetcher/Fetcher.php",
        "line": 166,
        "function": "getContent",
        "class": "OC\\Files\\SimpleFS\\SimpleFile",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/App/AppStore/Fetcher/AppFetcher.php",
        "line": 187,
        "function": "get",
        "class": "OC\\App\\AppStore\\Fetcher\\Fetcher",
        "type": "->",
        "args": [
          false
        ]
      },
      {
        "file": "/var/www/html/lib/private/Installer.php",
        "line": 423,
        "function": "get",
        "class": "OC\\App\\AppStore\\Fetcher\\AppFetcher",
        "type": "->",
        "args": [
          false
        ]
      },
      {
        "file": "/var/www/html/apps/settings/lib/Controller/AppSettingsController.php",
        "line": 154,
        "function": "isUpdateAvailable",
        "class": "OC\\Installer",
        "type": "->",
        "args": [
          "files_versions"
        ]
      },
      {
        "file": "/var/www/html/apps/settings/lib/Controller/AppSettingsController.php",
        "line": 137,
        "function": "getAppsWithUpdates",
        "class": "OCA\\Settings\\Controller\\AppSettingsController",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 230,
        "function": "viewApps",
        "class": "OCA\\Settings\\Controller\\AppSettingsController",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 137,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\Settings\\Controller\\AppSettingsController"
          ],
          "viewApps"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 184,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          [
            "OCA\\Settings\\Controller\\AppSettingsController"
          ],
          "viewApps"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 315,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Settings\\Controller\\AppSettingsController",
          "viewApps",
          [
            "OC\\AppFramework\\DependencyInjection\\DIContainer"
          ],
          [
            "",
            "",
            "settings.AppSettings.viewApps"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 1069,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/settings/apps"
        ]
      },
      {
        "file": "/var/www/html/index.php",
        "line": 37,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/html/lib/private/Files/Node/File.php",
    "Line": 56,
    "message": "",
    "exception": {},
    "CustomMessage": "Exception thrown: OCP\\Files\\GenericFileException"
  }
}

Steps to reproduce

  1. Clear appdata
  2. Internal server error
  3. 😞

Expected behavior

I assume it's okay that your instance is bricked if you deleted app data.

However, there are also some weird paths in our code.

} catch (NotFoundException $e) {
// File does not already exists
$file = $rootFolder->newFile($this->fileName);
}

Above code should handle that situation, a local copy of apps.json does not exist, properly.
It does not because a OCP\Files\GenericFileException is thrown instead of the expected OCP\Files\NotFoundException.

/**
* Get the content
*
* @throws NotPermittedException
* @throws NotFoundException
* @return string
*/
public function getContent() {
$result = $this->file->getContent();
if ($result === false) {
$this->checkFile();
}
return $result;
}

ISimpleFile.getContent does a check for false.
After #37943 the method does not return false but throws a OCP\Files\GenericFileException.

Installation method

None

Nextcloud Server version

master

Operating system

Debian/Ubuntu

PHP engine version

Other

Web server

Apache (supported)

Database engine version

None

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions