[Bug]: NC25.0.2 - TypeError for SimpleFolder in /var/www/nextcloud/lib/private/Files/AppData/AppData.php
⚠️ This issue respects the following points: ⚠️
- [X] This is a bug, not a question or a configuration/webserver/proxy issue.
- [X] This issue is not already reported on Github (I've searched it).
- [X] Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- [X] Nextcloud Server is running on 64bit capable CPU, PHP and OS.
- [X] I agree to follow Nextcloud's Code of Conduct.
Bug description
I get this Exception thrown a few times an hour, looking at the code I am sorry but could not figure out what was wrong.
TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
Steps to reproduce
Firstly thank you, think this is a great platform.
I been seeing this for awhile so though I should now report it, but strange I don't seem to see others reporting this, was also happening in NC24, and now NC25.0.2 on full patched Debian.
This is triggered by the cron jobs that NC runs.
Expected behavior
No exceptions in the log
Installation method
Community Manual installation with Archive
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.1
Web server
Apache (supported)
Database engine version
SQlite
Is this bug present after an update or on a fresh install?
Updated to a major version (ex. 22.2.3 to 23.0.1)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- [X] Default user-backend (database)
- [ ] LDAP/ Active Directory
- [ ] SSO - SAML
- [ ] Other
Configuration report
sudo -u www-data php occ config:list system
Cannot load Zend OPcache - it was already loaded
{
"system": {
"activity_expire_days": 90,
"auth.bruteforce.protection.enabled": true,
"blacklisted_files": [
".htaccess",
"Thumbs.db",
"thumbs.db"
],
"enable_previews": "false",
"preview_max_x": 100,
"preview_max_filesize_image": 1,
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"log_type": "file",
"loglevel": 3,
"logdateformat": "F d, Y H:i:s",
"logtimezone": "Europe\/London",
"trashbin_retention_obligation": "auto, 7",
"defaultapp": "calendar,files",
"memcache.local": "\\OC\\Memcache\\APCu",
"knowledgebaseenabledy": false,
"skeletondirectory": "",
"lost_password_link": "disabled",
"updatechecker": true,
"trusted_domains": [
"**I REMOVED SENSITIVE VALUE**",
"192.168.20.52:xxx",
"127.0.0.1:xxx"
],
"overwrite.cli.url": "https:\/\/**REMOVED SENSITIVE VALUE**:xxx",
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"dbtype": "sqlite3",
"version": "25.0.2.3",
"installed": true,
"maintenance": false,
"mail_smtpsecure": "ssl"
}
}
List of activated Apps
sudo -u www-data php occ app:list
Cannot load Zend OPcache - it was already loaded
Enabled:
- activity: 2.17.0
- admin_audit: 1.15.0
- bookmarks: 12.0.0
- calendar: 4.2.0
- circles: 25.0.0
- cloud_federation_api: 1.8.0
- comments: 1.15.0
- contacts: 5.0.2
- contactsinteraction: 1.6.0
- dashboard: 7.5.0
- dav: 1.24.0
- federatedfilesharing: 1.15.0
- federation: 1.15.0
- files: 1.20.1
- files_pdfviewer: 2.6.0
- files_rightclick: 1.4.0
- files_sharing: 1.17.0
- files_trashbin: 1.15.0
- files_versions: 1.18.0
- firstrunwizard: 2.14.0
- logreader: 2.10.0
- lookup_server_connector: 1.13.0
- nextcloud_announcements: 1.14.0
- notes: 4.6.0
- notifications: 2.13.1
- oauth2: 1.13.0
- password_policy: 1.15.0
- photos: 2.0.1
- privacy: 1.9.0
- provisioning_api: 1.15.0
- recommendations: 1.4.0
- related_resources: 1.0.3
- serverinfo: 1.15.0
- settings: 1.7.0
- sharebymail: 1.15.0
- support: 1.8.0
- survey_client: 1.13.0
- systemtags: 1.15.0
- tasks: 0.14.5
- text: 3.6.0
- theming: 2.0.1
- twofactor_backupcodes: 1.14.0
- updatenotification: 1.15.0
- user_status: 1.5.0
- viewer: 1.9.0
- weather_status: 1.5.0
- workflowengine: 2.7.0
Disabled:
- bruteforcesettings: 1.1.0
- encryption
- files_external
- suspicious_login
- twofactor_totp
- user_ldap
root@d86ed09c4605:/var/www/nextcloud#
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
This is just repeat many time here is a sample then an expanded example:
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
January 01, 2023 10:15:03
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
January 01, 2023 09:00:03
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
January 01, 2023 07:45:02
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
January 01, 2023 06:30:03
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
January 01, 2023 05:15:03
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
January 01, 2023 04:00:02
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
January 01, 2023 02:45:07
=================expanded example:
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
/var/www/nextcloud/lib/private/Files/AppData/AppData.php - line 140:
OC\Files\SimpleFS\SimpleFolder->__construct()
/var/www/nextcloud/lib/private/Preview/Storage/Root.php - line 57:
OC\Files\AppData\AppData->getFolder()
/var/www/nextcloud/lib/private/Preview/BackgroundCleanupJob.php - line 66:
OC\Preview\Storage\Root->getFolder()
/var/www/nextcloud/lib/private/BackgroundJob/Job.php - line 54:
OC\Preview\BackgroundCleanupJob->run()
/var/www/nextcloud/lib/private/BackgroundJob/TimedJob.php - line 60:
OC\BackgroundJob\Job->execute()
/var/www/nextcloud/cron.php - line 152:
OC\BackgroundJob\TimedJob->execute()
=======================and another
Error core TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140
/var/www/nextcloud/lib/private/Files/AppData/AppData.php - line 140:
OC\Files\SimpleFS\SimpleFolder->__construct()
/var/www/nextcloud/lib/private/Preview/Storage/Root.php - line 57:
OC\Files\AppData\AppData->getFolder()
/var/www/nextcloud/lib/private/Preview/BackgroundCleanupJob.php - line 66:
OC\Preview\Storage\Root->getFolder()
/var/www/nextcloud/lib/private/BackgroundJob/Job.php - line 54:
OC\Preview\BackgroundCleanupJob->run()
/var/www/nextcloud/lib/private/BackgroundJob/TimedJob.php - line 60:
OC\BackgroundJob\Job->execute()
/var/www/nextcloud/cron.php - line 152:
OC\BackgroundJob\TimedJob->execute()
Additional info
64Bit Debian ruining in a docker image on a 64 bit installation of RPI4 raspberry OS all full patched. uname -a Linux rpi4-cubox 5.15.84-v8+ #1610 SMP PREEMPT Mon Dec 19 18:54:50 GMT 2022 aarch64 GNU/Linux
docker -v
Docker version 20.10.22, build 3a2c30b
then inside the container:
uname -a
Linux d86ed09c4605 5.15.84-v8+ #1610 SMP PREEMPT Mon Dec 19 18:54:50 GMT 2022 aarch64 GNU/Linux
php --version
Cannot load Zend OPcache - it was already loaded PHP 8.1.13 (cli) (built: Nov 26 2022 14:27:02) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.13, Copyright (c) Zend Technologies with Zend OPcache v8.1.13, Copyright (c), by Zend Technologies
apache2 -v
Server version: Apache/2.4.54 (Debian) Server built: 2022-06-09T04:26:43
============ I have run the recommended scripts to secure the install, and the data section is held in a separate area. Everything seems to have been running fine... but my log file does fill up over time :-) so thought I should mention I am seeing this.
Error logs showing this is happening about every hour in my 25.0.4 instance (docker on RHEL9)
I am seeing the same error message here on my 26.0.2 instance. Are there any additional information that we can provide?
It seems that the message appeared in the nextcloud.log for quite a while already but since the update from 25.0.7 (or 25.0.6) to 26.0.2, I'm getting it via mail as well as it's now directly output by the cron task.
I'm seeing a very similar error twice a day during cron runs, with the following stack trace:
TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /home/nextcloud/www/lib/private/Files/AppData/AppData.php on line 140 and defined in /home/nextcloud/www/lib/private/Files/SimpleFS/SimpleFolder.php:43
Stack trace:
#0 /home/nextcloud/www/lib/private/Files/AppData/AppData.php(140): OC\Files\SimpleFS\SimpleFolder->__construct()
#1 /home/nextcloud/www/lib/private/Preview/Storage/Root.php(57): OC\Files\AppData\AppData->getFolder()
#2 /home/nextcloud/www/lib/private/Preview/BackgroundCleanupJob.php(68): OC\Preview\Storage\Root->getFolder()
#3 /home/nextcloud/www/lib/public/BackgroundJob/Job.php(78): OC\Preview\BackgroundCleanupJob->run()
#4 /home/nextcloud/www/lib/public/BackgroundJob/TimedJob.php(103): OCP\BackgroundJob\Job->start()
#5 /home/nextcloud/www/lib/public/BackgroundJob/TimedJob.php(93): OCP\BackgroundJob\TimedJob->start()
#6 /home/nextcloud/www/cron.php(152): OCP\BackgroundJob\TimedJob->execute()
#7 {main}
Nextcloud 26.0.2 with PHP 8.2.
After upgrading to NC 27.0, I'm no longer receiving these error messages.
I am seeing the same error very frequently during a cron run:
TypeError: OC\Files\SimpleFS\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\Files\Folder, OC\Files\Node\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140 and defined in /var/www/nextcloud/lib/private/Files/SimpleFS/SimpleFolder.php:43
Stack trace:
#0 /var/www/nextcloud/lib/private/Files/AppData/AppData.php(140): OC\Files\SimpleFS\SimpleFolder->__construct()
#1 /var/www/nextcloud/lib/private/Preview/Storage/Root.php(57): OC\Files\AppData\AppData->getFolder()
#2 /var/www/nextcloud/lib/private/Preview/BackgroundCleanupJob.php(68): OC\Preview\Storage\Root->getFolder()
#3 /var/www/nextcloud/lib/public/BackgroundJob/Job.php(78): OC\Preview\BackgroundCleanupJob->run()
#4 /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php(103): OCP\BackgroundJob\Job->start()
#5 /var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php(93): OCP\BackgroundJob\TimedJob->start()
#6 /var/www/nextcloud/cron.php(152): OCP\BackgroundJob\TimedJob->execute()
#7 {main}
Nextcloud v26.0.3 using the LDAP user backend.
After upgrading to NC 27.0, I'm no longer receiving these error messages.
After updating from 26 to 27.0.1, the regular emails stopped for me as well. But the error still occurs and the message is printed hourly to nextcloud.log. Here's a recent one from 27.0.1:
{"reqId":"********************","level":3,"time":"2023-07-28T04:44:03+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","message":"Error while running background job (class: OC\\Preview\\BackgroundCleanupJob, arguments: )","userAgent":"--","version":"27.0.1.2","exception":{"Exception":"TypeError","Message":"OC\\Files\\SimpleFS\\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\\Files\\Folder, OC\\Files\\Node\\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/AppData/AppData.php","line":140,"function":"__construct","class":"OC\\Files\\SimpleFS\\SimpleFolder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Preview/Storage/Root.php","line":57,"function":"getFolder","class":"OC\\Files\\AppData\\AppData","type":"->"},{"file":"/var/www/nextcloud/lib/private/Preview/BackgroundCleanupJob.php","line":68,"function":"getFolder","class":"OC\\Preview\\Storage\\Root","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/Job.php","line":86,"function":"run","class":"OC\\Preview\\BackgroundCleanupJob","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":103,"function":"start","class":"OCP\\BackgroundJob\\Job","type":"->"},{"file":"/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php","line":93,"function":"start","class":"OCP\\BackgroundJob\\TimedJob","type":"->"},{"file":"/var/www/nextcloud/cron.php","line":152,"function":"execute","class":"OCP\\BackgroundJob\\TimedJob","type":"->"}],"File":"/var/www/nextcloud/lib/private/Files/SimpleFS/SimpleFolder.php","Line":43,"message":"Error while running background job (class: OC\\Preview\\BackgroundCleanupJob, arguments: )","exception":{},"CustomMessage":"Error while running background job (class: OC\\Preview\\BackgroundCleanupJob, arguments: )"}}
Formatted message
{
"reqId": "********************",
"level": 3,
"time": "2023-07-28T04:44:03+00:00",
"remoteAddr": "",
"user": "--",
"app": "core",
"method": "",
"url": "--",
"message": "Error while running background job (class: OC\\Preview\\BackgroundCleanupJob, arguments: )",
"userAgent": "--",
"version": "27.0.1.2",
"exception": {
"Exception": "TypeError",
"Message": "OC\\Files\\SimpleFS\\SimpleFolder::__construct(): Argument #1 ($folder) must be of type OCP\\Files\\Folder, OC\\Files\\Node\\File given, called in /var/www/nextcloud/lib/private/Files/AppData/AppData.php on line 140",
"Code": 0,
"Trace": [
{
"file": "/var/www/nextcloud/lib/private/Files/AppData/AppData.php",
"line": 140,
"function": "__construct",
"class": "OC\\Files\\SimpleFS\\SimpleFolder",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Preview/Storage/Root.php",
"line": 57,
"function": "getFolder",
"class": "OC\\Files\\AppData\\AppData",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/private/Preview/BackgroundCleanupJob.php",
"line": 68,
"function": "getFolder",
"class": "OC\\Preview\\Storage\\Root",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/public/BackgroundJob/Job.php",
"line": 86,
"function": "run",
"class": "OC\\Preview\\BackgroundCleanupJob",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php",
"line": 103,
"function": "start",
"class": "OCP\\BackgroundJob\\Job",
"type": "->"
},
{
"file": "/var/www/nextcloud/lib/public/BackgroundJob/TimedJob.php",
"line": 93,
"function": "start",
"class": "OCP\\BackgroundJob\\TimedJob",
"type": "->"
},
{
"file": "/var/www/nextcloud/cron.php",
"line": 152,
"function": "execute",
"class": "OCP\\BackgroundJob\\TimedJob",
"type": "->"
}
],
"File": "/var/www/nextcloud/lib/private/Files/SimpleFS/SimpleFolder.php",
"Line": 43,
"message": "Error while running background job (class: OC\\Preview\\BackgroundCleanupJob, arguments: )",
"exception": {},
"CustomMessage": "Error while running background job (class: OC\\Preview\\BackgroundCleanupJob, arguments: )"
}
}
I'm seeing this on NC 28.0.1 :(
28.0.2 as well :(
Same 28.0.3
I'm on 28.0.4, using nextcloud fpm docker image running on k8s, same.
I finally figured out what caused the error on my instance. The folder appdata_*/preview/ in the data folder contained a file next to all the directories. I manually created that file at some point in time. However, Nextcloud only expects directories in there. After removing the file, the error is gone.
Could this be the reason for the others here as well?
ahhh, my data folder is on a macOS drive (because it's from a docker instal) and of course there is the hidden .DS_store file always creeping into folders. Let me check if this helps! Two cycles have passed without error - I guess this was the bug! Thank you!
I finally figured out what caused the error on my instance. The folder
appdata_*/preview/in the data folder contained a file next to all the directories. I manually created that file at some point in time. However, Nextcloud only expects directories in there. After removing the file, the error is gone.Could this be the reason for the others here as well?
Yes, I think that's the cause. I have a .nobackup file there. I think nextcloud should just ignore these hidden files.
I have a .nobackup file there.
That's exactly what I had in there as well. .DS_store or similar files (desktop.ini, thumbs.db) as mentioned by @DominusExult will trigger this as well.
If this is the underlying cause, I think it can safely be ignored. But it also makes me wonder if this error should at least be degraded to a warning or even a lower severity.