Skip to content

[Bug]: preview generation fails with S3 storage: "Parent folder not in filecache" #55530

@bazaah

Description

@bazaah

⚠️ This issue respects the following points: ⚠️

Bug description

When generating a preview via the OC\Preview\Generator->generatePreviews code path for a S3 backed nextcloud instance, previews will sometimes fail to generate with a stack trace like this:

Stack Trace

2025-10-03T14:23:20+00:00 In Cache.php line 274:
2025-10-03T14:23:20+00:00
2025-10-03T14:23:20+00:00   [Exception]
2025-10-03T14:23:20+00:00   Parent folder not in filecache for 0/b
2025-10-03T14:23:20+00:00
2025-10-03T14:23:20+00:00
2025-10-03T14:23:20+00:00 Exception trace:
2025-10-03T14:23:20+00:00   at /var/www/html/lib/private/Files/Cache/Cache.php:274
2025-10-03T14:23:20+00:00  OC\Files\Cache\Cache->insert() at /var/www/html/lib/private/Files/Cache/Cache.php:239
2025-10-03T14:23:20+00:00  OC\Files\Cache\Cache->put() at /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php:109
2025-10-03T14:23:20+00:00  OC\Files\ObjectStore\ObjectStoreStorage->mkdir() at /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php:94
2025-10-03T14:23:20+00:00  OC\Files\ObjectStore\ObjectStoreStorage->mkdir() at /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php:94
2025-10-03T14:23:20+00:00  OC\Files\ObjectStore\ObjectStoreStorage->mkdir() at /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php:94
2025-10-03T14:23:20+00:00  OC\Files\ObjectStore\ObjectStoreStorage->mkdir() at /var/www/html/lib/private/Files/ObjectStore/ObjectStoreStorage.php:94
2025-10-03T14:23:20+00:00  OC\Files\ObjectStore\ObjectStoreStorage->mkdir() at /var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php:58
2025-10-03T14:23:20+00:00  OC\Files\Storage\Wrapper\Wrapper->mkdir() at /var/www/html/lib/private/Files/View.php:1210
2025-10-03T14:23:20+00:00  OC\Files\View->basicOperation() at /var/www/html/lib/private/Files/View.php:211
2025-10-03T14:23:20+00:00  OC\Files\View->mkdir() at /var/www/html/lib/private/Files/Node/Folder.php:129
2025-10-03T14:23:20+00:00  OC\Files\Node\Folder->newFolder() at /var/www/html/lib/private/Files/AppData/AppData.php:129
2025-10-03T14:23:20+00:00  OC\Files\AppData\AppData->newFolder() at /var/www/html/lib/private/Preview/Storage/Root.php:56
2025-10-03T14:23:20+00:00  OC\Preview\Storage\Root->newFolder() at /var/www/html/lib/private/Preview/Generator.php:584
2025-10-03T14:23:20+00:00  OC\Preview\Generator->getPreviewFolder() at /var/www/html/lib/private/Preview/Generator.php:110
2025-10-03T14:23:20+00:00  OC\Preview\Generator->generatePreviews() at /var/www/html/lib/private/PreviewManager.php:188
2025-10-03T14:23:20+00:00  OC\PreviewManager->generatePreviews() at /var/www/html/apps/previewgenerator/lib/Command/Generate.php:210
2025-10-03T14:23:20+00:00  OCA\PreviewGenerator\Command\Generate->parseFile() at /var/www/html/apps/previewgenerator/lib/Command/Generate.php:192
2025-10-03T14:23:20+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/html/apps/previewgenerator/lib/Command/Generate.php:190
2025-10-03T14:23:20+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/html/apps/previewgenerator/lib/Command/Generate.php:190
2025-10-03T14:23:20+00:00  OCA\PreviewGenerator\Command\Generate->parseFolder() at /var/www/html/apps/previewgenerator/lib/Command/Generate.php:161
2025-10-03T14:23:20+00:00  OCA\PreviewGenerator\Command\Generate->generatePathPreviews() at /var/www/html/apps/previewgenerator/lib/Command/Generate.php:109
2025-10-03T14:23:20+00:00  OCA\PreviewGenerator\Command\Generate->execute() at /var/www/html/3rdparty/symfony/console/Command/Command.php:326
2025-10-03T14:23:20+00:00  Symfony\Component\Console\Command\Command->run() at /var/www/html/3rdparty/symfony/console/Application.php:1078
2025-10-03T14:23:20+00:00  Symfony\Component\Console\Application->doRunCommand() at /var/www/html/3rdparty/symfony/console/Application.php:324
2025-10-03T14:23:20+00:00  Symfony\Component\Console\Application->doRun() at /var/www/html/3rdparty/symfony/console/Application.php:175
2025-10-03T14:23:20+00:00  Symfony\Component\Console\Application->run() at /var/www/html/lib/private/Console/Application.php:187
2025-10-03T14:23:20+00:00  OC\Console\Application->run() at /var/www/html/console.php:87
2025-10-03T14:23:20+00:00  require_once() at /var/www/html/occ:33

This one was generate via a oc preview:generate-all call, but you can get the same thing calling oc preview:generate <the file path> on the buggy file, or just scrolling the photos or memories apps. This has existed for (at least) server versions 29, 30 and 31. The files it happens to are seemingly random, but it will consistently happen for a file once you find one.

The only commonality I can find is that the error's mentioned file path (e.g Parent folder not in filecache for <file path>) always has a zero 0 character in it.

Steps to reproduce

  1. Use an S3 backed Nextcloud server
  2. Attempt to generate a preview (e.g via oc or just browsing in the files or photos apps)
  3. Note the stack trace (or 503 in web tools) on some of the photos

Expected behavior

The preview should be generated

Nextcloud Server version

31

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.3

Web server

Apache (supported)

Database engine version

PostgreSQL

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

Updated from a MINOR version (ex. 32.0.1 to 32.0.2)

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": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "dbtype": "pgsql",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "dbpersistent": true,
        "default_language": "en",
        "default_locale": "en_US",
        "knowledgebaseenabled": true,
        "knowledgebase.embedded": false,
        "allow_user_to_change_display_name": true,
        "remember_login_cookie_lifetime": 691200,
        "session_lifetime": 86400,
        "davstorage.request_timeout": 30,
        "session_relaxed_expiry": true,
        "session_keepalive": true,
        "auto_logout": true,
        "token_auth_enforced": true,
        "token_auth_activity_update": 60,
        "auth.bruteforce.protection.enabled": true,
        "auth.storeCryptedPassword": true,
        "hide_login_form": false,
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": 25,
        "mail_smtptimeout": 10,
        "mail_template_class": "\\OC\\Mail\\EMailTemplate",
        "mail_send_plaintext_only": false,
        "htaccess.RewriteBase": "\/",
        "allow_local_remote_servers": true,
        "trashbin_retention_obligation": "90, 365",
        "versions_retention_obligation": "auto, 90",
        "appcodechecker": true,
        "updatechecker": true,
        "updater.release.channel": "stable",
        "config_is_read_only": false,
        "log_type": "file",
        "log_type_audit": "file",
        "logfilemode": 416,
        "loglevel": 2,
        "logtimezone": "UTC",
        "log_rotate_size": 67108864,
        "profiler": false,
        "defaultapp": "dashboard,files",
        "appstoreenabled": false,
        "enable_previews": true,
        "preview_concurrency_all": 8,
        "preview_concurrency_new": 4,
        "preview_max_filesize_image": 25,
        "preview_max_memory": 128,
        "enabledPreviewProviders": [
            "OC\\Preview\\BMP",
            "OC\\Preview\\GIF",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\Krita",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\MP3",
            "OC\\Preview\\OpenDocument",
            "OC\\Preview\\PNG",
            "OC\\Preview\\TXT",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\Imaginary",
            "OC\\Preview\\ImaginaryPDF"
        ],
        "maintenance": false,
        "maintenance_window_start": 1,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": "***REMOVED SENSITIVE VALUE***",
            "timeout": 5,
            "read_timeout": 5,
            "dbindex": 0
        },
        "objectstore_multibucket": {
            "class": "OC\\Files\\ObjectStore\\S3",
            "arguments": {
                "region": "***REMOVED SENSITIVE VALUE***",
                "bucket": "***REMOVED SENSITIVE VALUE***",
                "num_buckets": 256,
                "autocreate": true,
                "key": "***REMOVED SENSITIVE VALUE***",
                "secret": "***REMOVED SENSITIVE VALUE***",
                "hostname": "***REMOVED SENSITIVE VALUE***",
                "use_ssl": true,
                "use_path_style": true
            }
        },
        "objectstore.multibucket.preview-distribution": true,
        "sharing.enable_mail_link_password_expiration": true,
        "sharing.mail_link_password_expiration_interval": 3600,
        "sharing.minSearchStringLength": 2,
        "files_external_allow_create_new_local": false,
        "filesystem_cache_readonly": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_X_FORWARDED_FOR",
            "HTTP_X_REAL_IP"
        ],
        "max_filesize_animated_gifs_public_sharing": 10,
        "filelocking.enabled": true,
        "filelocking.ttl": 3600,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "upgrade.disable-web": true,
        "upgrade.cli-upgrade-link": "",
        "documentation_url.server_logs": "",
        "simpleSignUpLink.shown": false,
        "version": "31.0.4.1",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "memories.db.triggers.fcu": true,
        "memories.exiftool": "\/var\/www\/html\/apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/var\/www\/html\/apps\/memories\/bin-ext\/go-vod-amd64",
        "overwriteprotocol": "https",
        "memories.gis_type": 2,
        "default_phone_region": "US",
        "preview_imaginary_url": "***REMOVED SENSITIVE VALUE***",
        "preview_imaginary_key": "***REMOVED SENSITIVE VALUE***"
    }
}

List of activated Apps

Enabled:
  - activity: 4.0.0
  - app_api: 5.0.2
  - bruteforcesettings: 4.0.0
  - calendar: 5.5.5
  - circles: 31.0.0
  - cloud_federation_api: 1.14.0
  - comments: 1.21.0
  - contacts: 7.3.2
  - contactsinteraction: 1.12.0
  - dashboard: 7.11.0
  - dav: 1.33.0
  - federatedfilesharing: 1.21.0
  - federation: 1.21.0
  - files: 2.3.1
  - files_downloadlimit: 4.0.0
  - files_pdfviewer: 4.0.0
  - files_reminders: 1.4.0
  - files_sharing: 1.23.1
  - files_trashbin: 1.21.0
  - files_versions: 1.24.0
  - firstrunwizard: 4.0.0
  - logreader: 4.0.0
  - lookup_server_connector: 1.19.0
  - memories: 7.6.2
  - nextcloud_announcements: 3.0.0
  - notes: 4.12.3
  - notifications: 4.0.0
  - oauth2: 1.19.1
  - password_policy: 3.0.0
  - photos: 4.0.0-dev.1
  - previewgenerator: 5.10.0
  - privacy: 3.0.0
  - profile: 1.0.0
  - provisioning_api: 1.21.0
  - recommendations: 4.0.0
  - related_resources: 2.0.0
  - richdocuments: 8.7.5
  - serverinfo: 3.0.0
  - settings: 1.14.0
  - sharebymail: 1.21.0
  - snappymail: 2.38.2
  - support: 3.0.0
  - survey_client: 3.0.0
  - systemtags: 1.21.1
  - tasks: 0.16.1
  - text: 5.0.0
  - theming: 2.6.1
  - twofactor_backupcodes: 1.20.0
  - twofactor_totp: 13.0.0-dev.0
  - updatenotification: 1.21.0
  - user_status: 1.11.0
  - viewer: 4.0.0
  - weather_status: 1.11.0
  - webhook_listeners: 1.2.0
  - workflowengine: 2.13.0
Disabled:
  - admin_audit: 1.21.0
  - encryption: 2.19.0
  - files_external: 1.23.0
  - suspicious_login: 9.0.1
  - twofactor_nextcloud_notification: 5.0.0
  - user_ldap: 1.22.0

Nextcloud Signing status

Nextcloud Logs

Error    no app in context  Parent folder not in filecache for 0/2                                                             2025-10-03T15:39:38+00:00

  Error    no app in context  Parent folder not in filecache for 0/1                                                             2025-10-03T15:39:42+00:00

  Error    no app in context  Parent folder not in filecache for 0/2                                                             2025-10-03T15:39:42+00:00

  Error    no app in context  Parent folder not in filecache for 0/8                                                             2025-10-03T15:39:41+00:00

  Error    no app in context  Parent folder not in filecache for 0/1                                                             2025-10-03T15:39:42+00:00

  Error    no app in context  Parent folder not in filecache for 0/5                                                             2025-10-03T15:40:24+00:00

  Error    no app in context  Parent folder not in filecache for 0/5                                                             2025-10-03T15:40:24+00:00

  Error    no app in context  Parent folder not in filecache for 0/b                                                             2025-10-03T15:43:50+00:00

  Error    no app in context  Parent folder not in filecache for 0/0                                                             2025-10-03T15:43:23+00:00

  Error    no app in context  Parent folder not in filecache for 0/b                                                             2025-10-03T15:43:50+00:00

  Error    no app in context  Parent folder not in filecache for 0/4                                                             2025-10-03T15:43:50+00:00

Additional info

I am using docker.io/library/nextcloud:31.0.4 as the nextcloud image, docker.io/valkey/valkey:8 for redis and postgres 17 for my database.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Status

    Triaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions