nextcloud/approval

[Bug]: Approval workflows breaks file:scan for external added files

niepiotrek opened this issue · 0 comments

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

Nextcloud instance runs with external samba share.
When I enable Approval Workflow based on new created files on external share, Nextcloud stops syncing.
Files are available in Nextcloud, but size and date are not updated till I manually open folder in browser.

Steps to reproduce

  1. Create new Automated tagging flow ( Filename is TEST -> tag NEW_FILE )
  2. Create new Approval Workflow based on NEW_FILE tag
  3. Add file TEST to external samba share
  4. Run occ files:scan --all to sync external share
  5. Get Error: Call to a member function getUID() on null

Expected behavior

Files added to external storage should be scanned, autotaged and create aproval workflow

Installation method

Manual installation

Operating system

Debian/Ubuntu

PHP engine version

PHP 7.4

Web server

Apache (supported)

Database engine version

MariaDB

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

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

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

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "cloud.geodezja.info.pl"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "23.0.0.10",
        "overwrite.cli.url": "https:\/\/cloud.geodezja.info.pl\/",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "default_phone_region": "pl_PL",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379
        },
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "allow_local_remote_servers": true,
        "app_install_overwrite": [
            "user_saml",
            "flow_notifications",
            "roundcube",
            "ldap_write_support"
        ],
        "htaccess.RewriteBase": "\/",
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forcessl": true,
        "overwriteprotocol": "https",
        "maintenance": false,
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_smtpsecure": "tls",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - accessibility: 1.9.0
  - activity: 2.15.0
  - admin_audit: 1.13.0
  - approval: 1.0.9
  - bruteforcesettings: 2.3.0
  - calendar: 3.2.0
  - circles: 23.0.0
  - cloud_federation_api: 1.6.0
  - comments: 1.13.0
  - contacts: 4.0.8
  - contactsinteraction: 1.4.0
  - dashboard: 7.3.0
  - dav: 1.21.0
  - event_update_notification: 1.4.0
  - external: 3.10.2
  - extract: 1.3.3
  - federatedfilesharing: 1.13.0
  - files: 1.18.0
  - files_accesscontrol: 1.13.0
  - files_automatedtagging: 1.13.0
  - files_external: 1.15.0
  - files_markdown: 2.3.5
  - files_pdfviewer: 2.4.0
  - files_retention: 1.12.0
  - files_rightclick: 1.2.0
  - files_sharing: 1.15.0
  - files_trashbin: 1.13.0
  - files_versions: 1.16.0
  - files_videoplayer: 1.12.0
  - fileslibreofficeedit: 1.0.4
  - firstrunwizard: 2.12.0
  - flow_notifications: 1.2.0
  - geoblocker: 0.5.4
  - groupfolders: 11.1.2
  - impersonate: 1.10.0
  - logreader: 2.8.0
  - lookup_server_connector: 1.11.0
  - maps: 0.1.10
  - nextcloud_announcements: 1.12.0
  - notifications: 2.11.1
  - oauth2: 1.11.0
  - password_policy: 1.13.0
  - photos: 1.5.0
  - privacy: 1.7.0
  - provisioning_api: 1.13.0
  - richdocuments: 5.0.3
  - roundcube: 22.0.0
  - serverinfo: 1.13.0
  - settings: 1.5.0
  - sharebymail: 1.13.0
  - socialsharing_email: 2.4.0
  - survey_client: 1.11.0
  - systemtags: 1.13.0
  - text: 3.4.0
  - theming: 1.14.0
  - twofactor_backupcodes: 1.12.0
  - updatenotification: 1.13.0
  - user_ldap: 1.13.0
  - user_saml: 4.1.1
  - viewer: 1.7.0
  - workflow_pdf_converter: 1.8.0
  - workflow_script: 1.8.0
  - workflowengine: 2.5.0
Disabled:
  - deck
  - encryption
  - federation
  - ldap_write_support
  - recommendations
  - support
  - tasks
  - user_status
  - weather_status

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

Starting scan for user 5 out of 11 (username)
An unhandled exception has been thrown:
Error: Call to a member function getUID() on null in /var/www/nextcloud/apps/approval/lib/Service/ApprovalService.php:736
Stack trace:
#0 /var/www/nextcloud/apps/approval/lib/AppInfo/Application.php(77): OCA\Approval\Service\ApprovalService->handleTagAssignmentEvent()
nextcloud/server#1 /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php(251): OCA\Approval\AppInfo\Application->OCA\Approval\AppInfo\{closure}()
nextcloud/server#2 /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
nextcloud/server#3 /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php(88): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
nextcloud/server#4 /var/www/nextcloud/lib/private/EventDispatcher/SymfonyAdapter.php(100): OC\EventDispatcher\EventDispatcher->dispatch()
nextcloud/server#5 /var/www/nextcloud/lib/private/SystemTag/SystemTagObjectMapper.php(174): OC\EventDispatcher\SymfonyAdapter->dispatch()
nextcloud/server#6 /var/www/nextcloud/apps/files_automatedtagging/lib/Operation.php(98): OC\SystemTag\SystemTagObjectMapper->assignTags()
nextcloud/server#7 /var/www/nextcloud/apps/files_automatedtagging/lib/Listener/CacheListener.php(43): OCA\FilesAutomatedTagging\Operation->checkOperations()
nextcloud/server#8 /var/www/nextcloud/lib/private/EventDispatcher/ServiceEventListener.php(87): OCA\FilesAutomatedTagging\Listener\CacheListener->handle()
nextcloud/server#9 /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php(251): OC\EventDispatcher\ServiceEventListener->__invoke()
nextcloud/server#10 /var/www/nextcloud/3rdparty/symfony/event-dispatcher/EventDispatcher.php(73): Symfony\Component\EventDispatcher\EventDispatcher->callListeners()
nextcloud/server#11 /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php(88): Symfony\Component\EventDispatcher\EventDispatcher->dispatch()
nextcloud/server#12 /var/www/nextcloud/lib/private/EventDispatcher/EventDispatcher.php(100): OC\EventDispatcher\EventDispatcher->dispatch()
nextcloud/server#13 /var/www/nextcloud/lib/private/Files/Cache/Cache.php(324): OC\EventDispatcher\EventDispatcher->dispatchTyped()
nextcloud/server#14 /var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php(135): OC\Files\Cache\Cache->insert()
nextcloud/server#15 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(295): OC\Files\Cache\Wrapper\CacheWrapper->insert()
nextcloud/server#16 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(225): OC\Files\Cache\Scanner->addToCache()
nextcloud/server#17 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(437): OC\Files\Cache\Scanner->scanFile()
nextcloud/server#18 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(389): OC\Files\Cache\Scanner->handleChildren()
nextcloud/server#19 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(392): OC\Files\Cache\Scanner->scanChildren()
nextcloud/server#20 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(392): OC\Files\Cache\Scanner->scanChildren()
nextcloud/server#21 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(392): OC\Files\Cache\Scanner->scanChildren()
nextcloud/server#22 /var/www/nextcloud/lib/private/Files/Cache/Scanner.php(341): OC\Files\Cache\Scanner->scanChildren()
nextcloud/server#23 /var/www/nextcloud/lib/private/Files/Utils/Scanner.php(262): OC\Files\Cache\Scanner->scan()
nextcloud/server#24 /var/www/nextcloud/apps/files/lib/Command/Scan.php(143): OC\Files\Utils\Scanner->scan()
nextcloud/server#25 /var/www/nextcloud/apps/files/lib/Command/Scan.php(199): OCA\Files\Command\Scan->scanFiles()
#26 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(255): OCA\Files\Command\Scan->execute()
nextcloud/server#27 /var/www/nextcloud/core/Command/Base.php(168): Symfony\Component\Console\Command\Command->run()
nextcloud/server#28 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1009): OC\Core\Command\Base->run()
nextcloud/server#29 /var/www/nextcloud/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
nextcloud/server#30 /var/www/nextcloud/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
nextcloud/server#31 /var/www/nextcloud/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run()
nextcloud/server#32 /var/www/nextcloud/console.php(99): OC\Console\Application->run()
nextcloud/server#33 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

Additional info

I found that Nextcloud stops syncing because of missing UID,
on ApprovalService.php:723 there is:

 // search our activities to see if we know who made the request
...
// if there is no activity, the tag was assigned manually (or via auto-tagging flows)
// => perform the request here (share, store action and trigger activity event)
...
           // we can assume the file owner is the one who requests
              $requestUserId = $node->getOwner()->getUID();

but file is from external storage, so getOwner() is null

I workaround this by assigning external files to admin UID.

Dirty hack:

nextcloud/apps/approval/lib/Service/ApprovalService.php:736

//                      $requestUserId = $node->getOwner()->getUID();
                        if (is_null($node->getOwner())) {
                                $requestUserId = 'Administrator';
                        } else {
                                $requestUserId = $node->getOwner()->getUID();
                        }

It's not universal, but syncing with external share works.
Push notifications not working but this may be related to nextcloud/server#30900