[solved] Internal Server Error with FolderSync

Hi Everyone,

please find below the filled out issue template:

Nextcloud version (eg, 20.0.5): 20.0.5
Operating system and version (eg, Ubuntu 20.04): 20.04 in Proxmox LXC
Apache or nginx version (eg, Apache 2.4.25): 2.4.41
PHP version (eg, 7.4): php 7.4.3

The issue you are facing:

I’m trying to upload files with FolderSync to my nextcloud instance. The sync completes partially successful, but some files cannot be synced with the error (in FolderSync) stating ‘internal server error’. I can see the error in the Apache Reverse proxy log (see log snipped at the bottom). The Nextcloud log throws repetedly strange errors (see log snippet below).

Not sure if this is relevant, but i am using the LDAP server of my Synology NAS. The LDAP settings tell me, that everything is fine and set up properly (all green).

Is this the first time you’ve seen this error? (Y/N): Y

This error occured after migrating from Nextcloud 18 to 19. The upgrade ran smooth, no issues so far, except this one. Afterwards i migrated from 19 to 20.05 in the hope, that this would fix the issue.
Additionally, i upgraded the underlying ubuntu from 18.04 LTS to 20.04 LTS including an upgrade of PHP 7.2 to PHP 7.4. Still, the issue persisits.

Steps to replicate it:

  1. Setup FolderSync for Android to sync any folder with your nextcloud. Make sure to use a folder with large files like photos (~4-5MB).

The output of your Nextcloud log in Admin > Logging:
this type of error is periodically appearing in the log

{"reqId":"Imonqv9Cukf4XfUrgOuw","level":4,"time":"2021-02-01T22:01:14+00:00","remoteAddr":"192.168.0.134","user":"Michael","app":"webdav","method":"MOVE","url":"/remote.php/dav/uploads/Michael/web-file-upload-044272bcf117c4d0414ddb9af9553b50-1612216871750/.file","message":{"Exception":"TypeError","Message":"in_array() expects parameter 2 to be array, null given","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/workflowengine/lib/Service/RuleMatcher.php","line":168,"function":"in_array"},{"file":"/var/www/nextcloud/apps/workflowengine/lib/Service/RuleMatcher.php","line":124,"function":"getMatchingOperations","class":"OCA\\WorkflowEngine\\Service\\RuleMatcher","type":"->"},{"file":"/var/www/nextcloud/apps/workflow_pdf_converter/lib/Operation.php","line":110,"function":"getFlows","class":"OCA\\WorkflowEngine\\Service\\RuleMatcher","type":"->"},{"file":"/var/www/nextcloud/apps/workflowengine/lib/AppInfo/Application.php","line":101,"function":"onEvent","class":"OCA\\WorkflowPDFConverter\\Operation","type":"->"},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":251,"function":"OCA\\WorkflowEngine\\AppInfo\\{closure}","class":"OCA\\WorkflowEngine\\AppInfo\\Application","type":"->","args":["*** sensitive parameters replaced ***"]},{"file":"/var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php","line":73,"function":"callListeners","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php","line":86,"function":"dispatch","class":"Symfony\\Component\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/EventDispatcher/SymfonyAdapter.php","line":72,"function":"dispatch","class":"OC\\EventDispatcher\\EventDispatcher","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/HookConnector.php","line":134,"function":"dispatch","class":"OC\\EventDispatcher\\SymfonyAdapter","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Hook.php","line":110,"function":"postCreate","class":"OC\\Files\\Node\\HookConnector","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","line":407,"function":"emit","class":"OC_Hook","type":"::"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/File.php","line":340,"function":"emitPostHooks","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":155,"function":"put","class":"OCA\\DAV\\Connector\\Sabre\\File","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":311,"function":"createFile","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":135,"function":"copyNode","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":167,"function":"copy","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Upload/ChunkingPlugin.php","line":95,"function":"move","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Upload/ChunkingPlugin.php","line":77,"function":"performMove","class":"OCA\\DAV\\Upload\\ChunkingPlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"beforeMove","class":"OCA\\DAV\\Upload\\ChunkingPlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":632,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpMove","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":474,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":251,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":319,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":332,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":167,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/workflowengine/lib/Service/RuleMatcher.php","Line":168,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0","version":"20.0.5.2","id":"60187e08dafe7"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'apidjfjaufwi',
  'installed' => true,
  'dbname' => 'nextcloud',
  'dbhost' => '192.168.0.213',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '***',
  'dbpassword' => '***',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '0.0.0.1',
    'port' => 6379,
  ),
  'datadirectory' => '/mnt/data',
  'version' => '20.0.5.2',
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' => 
  array (
    0 => '192.168.0.25',
    1 => 'mydomain.de',
    2 => '192.168.0.24',
  ),
  'trusted_proxies' => 
  array (
    0 => '192.168.0.24',
  ),
  'dbtype' => 'mysql',
  'overwrite.cli.url' => 'https://mydomain.de',
  'overwritehost' => 'mydomain.de',
  'overwriteprotocol' => 'https',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_from_address' => 'info',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'mydomain.de',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.mail.de',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'webmaster@mydomain.de',
  'mail_smtppassword' => '***',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'encryption.legacy_format_support' => false,
);

The output of your Apache/nginx/system log in /var/log/access.log:

192.168.0.24 - - [25/Jan/2021:19:32:57 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_090841.jpg HTTP/1.1" 500 1672 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:02 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_105908.jpg HTTP/1.1" 500 1668 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:09 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_105908.jpg HTTP/1.1" 500 1666 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:14 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_150656.jpg HTTP/1.1" 500 1670 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:21 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_150656.jpg HTTP/1.1" 500 1672 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:24 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151300.jpg HTTP/1.1" 500 1676 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:31 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151300.jpg HTTP/1.1" 500 1670 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:35 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151303.jpg HTTP/1.1" 500 1668 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:41 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151303.jpg HTTP/1.1" 500 1668 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:45 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151306.jpg HTTP/1.1" 500 1678 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:52 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151306.jpg HTTP/1.1" 500 1672 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:33:55 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151310.jpg HTTP/1.1" 500 1680 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:34:01 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_151310.jpg HTTP/1.1" 500 1662 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:34:05 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_095406.jpg HTTP/1.1" 500 1666 "-" "OkHttp"
192.168.0.24 - - [25/Jan/2021:19:34:12 +0000] "PUT /remote.php/dav/files/Michael/Fotos/Handy/20210119_095406.jpg HTTP/1.1" 500 1678 "-" "OkHttp"

It seems, that this post was some kind of rubber duck debugging for me.
After i made this post i took a deeper look on the log and saw this

/var/www/nextcloud/apps/workflowengine/lib/Service/RuleMatcher.php

After that i disabled all workflow apps and voila the upload was working again. I guess something went wrong in the workflowengine. I remember i setup some kind of workflow for testing purposes, but i didn’t really used it.