nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
26.89k stars 4.01k forks source link

Update to NC 19.0.1: Internal server error after login #21885

Closed dh-connect closed 3 years ago

dh-connect commented 4 years ago

Steps to reproduce

  1. Updated from NC 19.0.0 to 19.0.1 without problem using web installer
  2. After update login screen shows up
  3. Try to login, after successful login it switches to page with internal server error

Expected behaviour

after successful login switch to files

Actual behaviour

internal server error

Server configuration

Operating system: linux debian 10 buster

Web server: Apache 2.4.38

Database: MariaDB 10.3.22

PHP version: 7.4.8

Nextcloud version: 19.0.1

Updated from an older Nextcloud/ownCloud or fresh install: update from 19.0.0

Where did you install Nextcloud from: web installer

Signing status:

Signing status ``` cannot get to this page due to internal server error ```

List of activated apps:

App list ``` Enabled: - accessibility: 1.5.0 - activity: 2.12.0 - admin_audit: 1.9.0 - calendar: 2.0.3 - cloud_federation_api: 1.2.0 - comments: 1.9.0 - contacts: 3.3.0 - contactsinteraction: 1.0.0 - dav: 1.15.0 - encryption: 2.7.0 - federatedfilesharing: 1.9.0 - federation: 1.9.0 - files: 1.14.0 - files_external: 1.10.0 - files_pdfviewer: 1.8.0 - files_rightclick: 0.16.0 - files_sharing: 1.11.0 - files_trashbin: 1.9.0 - files_versions: 1.12.0 - files_videoplayer: 1.8.0 - logreader: 2.4.0 - lookup_server_connector: 1.7.0 - mail: 1.4.1 - news: 14.1.11 - nextcloud_announcements: 1.8.0 - notes: 3.6.0 - notifications: 2.7.0 - oauth2: 1.7.0 - ocsms: 2.1.8 - password_policy: 1.9.1 - photos: 1.1.0 - privacy: 1.3.0 - provisioning_api: 1.9.0 - qownnotesapi: 20.1.0 - recommendations: 0.7.0 - serverinfo: 1.9.0 - settings: 1.1.0 - sharebymail: 1.9.0 - spreed: 9.0.1 - support: 1.2.1 - systemtags: 1.9.0 - tasks: 0.13.2 - text: 3.0.1 - theming: 1.10.0 - twofactor_backupcodes: 1.8.0 - twofactor_totp: 4.1.3 - updatenotification: 1.9.0 - viewer: 1.3.0 - workflowengine: 2.1.0 Disabled: - firstrunwizard - survey_client - user_ldap ```

Nextcloud configuration:

Config report ``` { "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "10.0.0.10" ], "trusted_proxies": "***REMOVED SENSITIVE VALUE***", "datadirectory": "***REMOVED SENSITIVE VALUE***", "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***", "log_type": "owncloud", "logfile": "\/var\/log\/nextcloud.log", "loglevel": 2, "log_rotate_size": 104857600, "dbtype": "mysql", "version": "19.0.1.1", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "logtimezone": "UTC", "installed": true, "mail_smtpmode": "smtp", "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_smtpauthtype": "LOGIN", "mail_smtpauth": 1, "mail_smtpsecure": "tls", "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpname": "***REMOVED SENSITIVE VALUE***", "mail_smtppassword": "***REMOVED SENSITIVE VALUE***", "appstoreenabled": true, "appstore.experimental.enabled": true, "theme": "", "maintenance": false, "memcache.local": "\\OC\\Memcache\\APCu", "cache_path": "\/data\/ownclouddata\/ocd\/cache", "mail_smtpport": "587", "app.mail.server-side-cache.enabled": true, "htaccess.RewriteBase": "\/owncloud", "updater.release.channel": "stable", "mysql.utf8mb4": true, "memcache.locking": "\\OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": 0, "timeout": 0 }, "filelocking.enabled": true, "activity_expire_days": 14, "auth.bruteforce.protection.enabled": true, "blacklisted_files": [ ".htaccess", "Thumbs.db", "thumbs.db", "DS_Store" ], "cron_log": true, "enable_previews": true, "enabledPreviewProviders": [ "OC\\Preview\\PNG", "OC\\Preview\\JPEG", "OC\\Preview\\GIF", "OC\\Preview\\BMP", "OC\\Preview\\XBitmap", "OC\\Preview\\Movie", "OC\\Preview\\PDF", "OC\\Preview\\MP3", "OC\\Preview\\TXT", "OC\\Preview\\MarkDown" ], "preview_max_x": 1024, "preview_max_y": 768, "preview_max_scale_factor": 1, "filesystem_check_changes": 0, "integrity.check.disabled": false, "knowledgebaseenabled": false, "overwriteprotocol": "https", "quota_include_external_storage": false, "trashbin_retention_obligation": "auto, 7", "app_install_overwrite": [ "ocsms", "contacts", "qownnotesapi" ], "updater.secret": "***REMOVED SENSITIVE VALUE***" } } ```

Are you using external storage, if yes which one: smb

Are you using encryption: no

Are you using an external user-backend, if yes which one: no

LDAP configuration (delete this part if not used)

LDAP config ``` no LDAP ```

Client configuration

Browser:

Operating system:

Logs

Web server error log

Web server error log ``` no error in apache2/error.log ```

Nextcloud log (data/nextcloud.log)

Nextcloud log ``` same error over and over again "Exception":"TypeError: Return value of OC\\Group\\Database::getDisplayName() must be of the type string, null returned at /data/ownclouddata/www/owncloud/lib/private/Group/Database.php#444" ```

Browser log

Browser log ``` no browser log ```
dh-connect commented 4 years ago

Info: downgraded back to NC 19.0.0.12, and NC works again without internal server error.

danieljkemp commented 4 years ago

Same issue;

"Exception":"TypeError: Return value of OC\Group\Database::getDisplayName() must be of the type string, null returned at /data/ownclouddata/www/owncloud/lib/private/Group/Database.php#444"

That code block was added in 5ebb53593c88966454879ce4aedbe4c337efaf40; commenting it out seems to be a workaround. I am able to browse groups, in the admin UI once I've logged in, so I am not sure why the error is thrown on login.

dh-connect commented 4 years ago

thank you so much, workaround worked.

rolandixor commented 4 years ago

Is it specifically line 444 that you commented out? I tried this and it didn't seem to work for me.

It would be helpful if you could be more specific about what you commented out, as there are multiple things listed in the commit.

danieljkemp commented 4 years ago

No, it was the cache check code block. I'm not sure if the group cache is not yet populated when it runs, or if the group cache itself is broken, as I'm not familiar with the code base. I commented out lines 443-445.

Beware that this will skip use of the cache entirely for and might have apreformance penalty. Caveat emptor.

On Mon, Jul 20, 2020, 21:00 RolandiXor notifications@github.com wrote:

Is it specifically line 444 that you commented out? I tried this and it didn't seem to work for me.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/nextcloud/server/issues/21885#issuecomment-661512036, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACON7ON6LB3DRRA6OH2UPHDR4TSCLANCNFSM4O5K76YQ .

robinelfrink commented 4 years ago

Same issue here, upgrading from 18.0.8 to 19.0.2. Commenting the three lines in getDisplayName as a workaround does the trick.

dh-connect commented 4 years ago

instead of commenting it out, you can also handle the null value of displayname like this:

      public function getDisplayName(string $gid): string {

            if (isset($this->groupCache[$gid])) {

                    $displayName = $this->groupCache[$gid]['displayname'];

                        if (!isset($displayName) || trim($displayName) === '') {
                     $displayName = '';

                    return $displayName;
            }
      }
cnaumer commented 4 years ago

We have the same Problem. NC 19.0.2 and LDAP backend. However, until now I only got one user not working the rest (~100) have not complained. As we are using an AD as LDAP backend and there are no displaynames set on any groups I am not sure what makes this user different. I am waiting for feedback if the comment from dh-connect works as a fix.

kbzowski commented 4 years ago

I can confirm that problem still exists in 19.0.2 (pure local user storage). My solution: comment lines 455-457 (if condition) in /var/www/html/lib/private/Group/Database.php. Browse list of users in nextcloud (this will populate cache), and uncommnent previously commented code. After that operation it works fine. I believed something is wrong with not populated properly cache.

cnaumer commented 4 years ago

I can also confirm that the Problem still exists in 19.0.3 and the comment from dh-connect works as a fix with that version also.

vascowhite commented 4 years ago

I have three instances of NC running, all on Debian/Apache. This is happening on just one of the instances. I'm trying to upgrade to 19.03 from 18.9. Success on two instances, but failed with this error on one.

I have noticed that error message below gives the args as onboard, but the group name is actually Onboard. So maybe the issue is elsewhere?

Here's the error formatted for easier reading.

{
  "reqId": "j786idl9YWVSr1YOvjUR",
  "level": 3,
  "time": "2020-09-13T11:15:39+00:00",
  "remoteAddr": "172.18.74.176",
  "user": "paul",
  "app": "index",
  "method": "GET",
  "url": "/",
  "message": {
    "Exception": "TypeError",
    "Message": "Return value of OC\\Group\\Database::getDisplayName() must be of the type string, null returned",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/Group/Database.php",
        "line": 474,
        "function": "getDisplayName",
        "class": "OC\\Group\\Database",
        "type": "->",
        "args": [
          "onboard"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Group/Manager.php",
        "line": 187,
        "function": "getGroupDetails",
        "class": "OC\\Group\\Database",
        "type": "->",
        "args": [
          "onboard"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Group/Manager.php",
        "line": 175,
        "function": "getGroupObject",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          "onboard"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Group/Manager.php",
        "line": 287,
        "function": "get",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          "onboard"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Group/Manager.php",
        "line": 271,
        "function": "getUserIdGroups",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          "paul"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Group/Manager.php",
        "line": 335,
        "function": "getUserGroups",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\User\\User"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/groupfolders/lib/Folder/FolderManager.php",
        "line": 442,
        "function": "getUserGroupIds",
        "class": "OC\\Group\\Manager",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\User\\User"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/groupfolders/lib/Mount/MountProvider.php",
        "line": 80,
        "function": "getFoldersForUser",
        "class": "OCA\\GroupFolders\\Folder\\FolderManager",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\User\\User"
          },
          62
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/groupfolders/lib/Mount/MountProvider.php",
        "line": 84,
        "function": "getFoldersForUser",
        "class": "OCA\\GroupFolders\\Mount\\MountProvider",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\User\\User"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Config/MountProviderCollection.php",
        "line": 105,
        "function": "getMountsForUser",
        "class": "OCA\\GroupFolders\\Mount\\MountProvider",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\User\\User"
          },
          {
            "__class__": "OC\\Files\\Storage\\StorageFactory"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
        "line": 451,
        "function": "addMountForUser",
        "class": "OC\\Files\\Config\\MountProviderCollection",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\User\\User"
          },
          {
            "__class__": "OC\\Files\\Mount\\Manager"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Files/Filesystem.php",
        "line": 376,
        "function": "initMountPoints",
        "class": "OC\\Files\\Filesystem",
        "type": "::",
        "args": [
          "paul"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Util.php",
        "line": 308,
        "function": "init",
        "class": "OC\\Files\\Filesystem",
        "type": "::",
        "args": [
          "paul",
          "/paul/files"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1011,
        "function": "setupFS",
        "class": "OC_Util",
        "type": "::",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 37,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Group/Database.php",
    "Line": 456,
    "CustomMessage": "--"
  },
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
  "version": "19.0.3.1"
}
{
  "reqId": "j786idl9YWVSr1YOvjUR",
  "level": 3,
  "time": "2020-09-13T11:15:40+00:00",
  "remoteAddr": "172.18.74.176",
  "user": "paul",
  "app": "PHP",
  "method": "GET",
  "url": "/",
  "message": "TypeError: Return value of OC\\Group\\Database::getDisplayName() must be of the type string, null returned at /var/www/nextcloud/lib/private/Group/Database.php#456",
  "userAgent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0",
  "version": "19.0.3.1"
}
vascowhite commented 4 years ago

No further movement on fixing this?

danieljkemp commented 3 years ago

Still ended up with this issue in 20.0.0

cremfert commented 3 years ago

Same here, I had to go back to NC 18 as I got the Internal Server Error message, even after patching the getDisplayName() function.

cnaumer commented 3 years ago

Just updated to 19.0.5. Still the same problem.

dh-connect commented 3 years ago

Updated to 20.0.4 - still same issue, now internal error appears when switching to user settings, wonder why this is still not being fixed.

rolandixor commented 3 years ago

I stopped trying to upgrade because of this. Instead, I'm going to try to backup and migrate when I get the chance. That may be the only solution. As for support, IMHO, forget about it.

freumichCH commented 3 years ago

Hello all. We upgraded our infrastructure on sunday from 18.0.12 to 19.0.6 with the same error. Following fix has solved the issue:

instead of commenting it out, you can also handle the null value of displayname like this:

      public function getDisplayName(string $gid): string {

            if (isset($this->groupCache[$gid])) {

                    $displayName = $this->groupCache[$gid]['displayname'];

                        if (!isset($displayName) || trim($displayName) === '') {
                     $displayName = '';

                    return $displayName;
            }
      }

Is there any update on this?

pfy commented 3 years ago

We have found a workaround (this may help triage the problem): The SQL table oc_ldap_group_mapping contained a entry, where the cnof the ldap_dn was NOT the owncloud_name. By changing the `owncloud_name to the cn of the ldap entry, the problem went away.

antondollmaier commented 3 years ago

Issue is still present in 20.0.4. Haven't yet searched how the groupcache is wrongly populated.

thoro commented 3 years ago

Also with 20.0.5 ... maybe someone cares about checking that?

the oc_ldap_group_mapping table has the owncloud_name the same as the CN, but cn is all lower case, and owncloud_name is correctly typed (i.e. mixed case)

For me it seems to always affect only a single user at a time so far.

soerpoers commented 3 years ago

Seems that it's also the same with 20.0.6 I don't use ldap so there isn't a table of that there. All users except admins have this problem.

soerpoers commented 3 years ago

So I just solved the problem for me by deleting some records of users in the oc_group_user table, whose groups I had actually deleted in the frontend some time ago. But the records of the users associated with the groups were still there in the database and thus probably triggered the problem after each update.

dh-connect commented 3 years ago

thank you for the hint, I did the same, had users assigned to a group GID "users", but in table oc_groups is no GID "users", tried it out without the fix and it works now, so guess the issue was a GID used that's not in the oc_groups table

robinelfrink commented 3 years ago

List user/group combinations with non-existing group:

SELECT oc_group_user.* FROM oc_group_user LEFT JOIN oc_groups ON oc_group_user.gid=oc_groups.gid WHERE oc_groups.gid IS NULL;

Remove user/group combinations with non-existing group:

DELETE oc_group_user FROM oc_group_user LEFT JOIN oc_groups ON oc_group_user.gid=oc_groups.gid WHERE oc_groups.gid IS NULL;
vascowhite commented 3 years ago

@robinelfrink @soerpoers Thank you, that worked perfectly.

szaimen commented 3 years ago

Looks like this was fixed with https://github.com/nextcloud/server/pull/23065