Preview generation fails, if richdocuments are active

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 33.0.5.1
  • Operating sysietem and version (e.g., Ubuntu 24.04):
    • Debian Trixe
  • Web server and version (e.g, Apache 2.4.25):
    • nginx 2.6.3
  • PHP version (e.g, 8.3):
    • 8.4
  • Is this the first time you’ve seen this error? (Yes / No):
    • yes
  • When did this problem seem to first start?
    • no idea
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • archive

Summary of the issue you are facing:

When is try to generate previews with either occ preview:pre-generate or occ preview:generate-all, i get the following error and the script exits:

An unhandled exception has been thrown:
TypeError: fclose(): supplied resource is not a valid stream resource in /var/www/nextcloud/apps/richdocuments/lib/Service/RemoteService.php:72
Stack trace:
#0 /var/www/nextcloud/apps/richdocuments/lib/Service/RemoteService.php(72): fclose()
#1 /var/www/nextcloud/apps/richdocuments/lib/Preview/Office.php(55): OCA\\Richdocuments\\Service\\RemoteService->convertFileTo()
#2 /var/www/nextcloud/lib/private/Preview/GeneratorHelper.php(25): OCA\\Richdocuments\\Preview\\Office->getThumbnail()
#3 /var/www/nextcloud/lib/private/Preview/Generator.php(381): OC\\Preview\\GeneratorHelper->getThumbnail()
#4 /var/www/nextcloud/lib/private/Preview/Generator.php(335): OC\\Preview\\Generator->generateProviderPreview()
#5 /var/www/nextcloud/lib/private/Preview/Generator.php(126): OC\\Preview\\Generator->getMaxPreview()
#6 /var/www/nextcloud/lib/private/PreviewManager.php(185): OC\\Preview\\Generator->generatePreviews()
#7 /var/www/nextcloud/apps/previewgenerator/lib/Service/PreGenerateService.php(160): OC\\PreviewManager->generatePreviews()
#8 /var/www/nextcloud/apps/previewgenerator/lib/Service/PreGenerateService.php(141): OCA\\PreviewGenerator\\Service\\PreGenerateService->processFile()
#9 /var/www/nextcloud/apps/previewgenerator/lib/Service/PreGenerateService.php(110): OCA\\PreviewGenerator\\Service\\PreGenerateService->processRow()
#10 /var/www/nextcloud/apps/previewgenerator/lib/Service/PreGenerateService.php(73): OCA\\PreviewGenerator\\Service\\PreGenerateService->startProcessing()
#11 /var/www/nextcloud/apps/previewgenerator/lib/Command/PreGenerate.php(42): OCA\\PreviewGenerator\\Service\\PreGenerateService->preGenerate()
#12 /var/www/nextcloud/3rdparty/symfony/console/Command/Command.php(326): OCA\\PreviewGenerator\\Command\\PreGenerate->execute()
#13 /var/www/nextcloud/3rdparty/symfony/console/Application.php(1083): Symfony\\Component\\Console\\Command\\Command->run()
#14 /var/www/nextcloud/3rdparty/symfony/console/Application.php(324): Symfony\\Component\\Console\\Application->doRunCommand()
#15 /var/www/nextcloud/3rdparty/symfony/console/Application.php(175): Symfony\\Component\\Console\\Application->doRun()
#16 /var/www/nextcloud/lib/private/Console/Application.php(187): Symfony\\Component\\Console\\Application->run()
#17 /var/www/nextcloud/console.php(92): OC\\Console\\Application->run()
#18 /var/www/nextcloud/occ(33): require_once('...')
#19 {main}

Since richdocuments seems to the root cause, i have disabled via occ apps:disable richdocuments. After that, preview generation works fine without errors.

Steps to replicate it (hint: details matter!):

See description above

Configuration

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "serverid": 1,
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "version": "33.0.5.1",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "installed": true,
        "default_language": "de",
        "default_timezone": "Europe\/Amsterdam",
        "memories.db.triggers.fcu": true,
        "memories.exiftool": "\/var\/www\/nextcloud\/apps\/memories\/bin-ext\/exiftool-aarch64-glibc",
        "memories.vod.path": "\/var\/www\/nextcloud\/apps\/memories\/bin-ext\/go-vod-aarch64",
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
        "memories.vod.disable": true,
        "memories.video_default_quality": "-2",
        "memories.vod.use_transpose": true,
        "memories.vod.use_gop_size": true,
        "memories.gis_type": 1,
        "memories.index.mode": "3",
        "memories.index.path.blacklist": "\\\/@(Recycle|eaDir|calibre)\\\/",
        "memories.index.path": "\/Photos",
        "enable_previews": true,
        "enabledPreviewProviders": [
            "OC\\Preview\\JPEG",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\WEBP",
            "OC\\Preview\\MP3",
            "OC\\Preview\\Image",
            "OC\\Preview\\Movie"
        ],
        "preview_max_x": 1920,
        "preview_max_y": 1920,
        "preview_max_scale_factor": 1,
        "preview_max_filesize_image": 100,
        "jpeg_quality": 60,
        "default_phone_region": "EN",
        "integrity.check.disabled": false,
        "knowledgebaseenabled": false,
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "pipe",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauth": true,
        "mail_smtpport": "465",
        "debug": false,
        "overwriteprotocol": "https",
        "activity_expire_days": 14,
        "auth.bruteforce.protection.enabled": true,
        "ratelimit.protection.enabled": true,
        "trashbin_retention_obligation": "auto, 7",
        "logfile": "\/var\/log\/nextcloud\/nextcloud.log",
        "logtimezone": "Europe\/Amsterdam",
        "loglevel": 2,
        "log_rotate_size": 0,
        "remember_login_cookie_lifetime": 1296000,
        "session_lifetime": 86400,
        "session_keepalive": true,
        "auto_logout": true,
        "profile.enabled": false,
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 1,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "app_install_overwrite": [],
        "twofactor_enforced": "true",
        "twofactor_enforced_groups": [],
        "twofactor_enforced_excluded_groups": [
            "test"
        ],
        "defaultapp": "files",
        "forbidden_filename_characters": [
            "<",
            ">",
            ":",
            "\"",
            "|",
            "?",
            "*",
            "\\",
            "\/"
        ],
        "forbidden_filename_extensions": [
            " ",
            ".",
            ".filepart",
            ".part"
        ],
        "filesystem_check_changes": 0,
        "maintenance_window_start": 1,
        "maintenance": false,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "theme": "",
        "cron_log": true,
        "forbidden_filenames": [
            ".htaccess",
            "Thumbs.db",
            "thumbs.db"
        ],
        "forbidden_filename_basenames": [
            "con",
            "prn",
            "aux",
            "nul",
            "com0",
            "com1",
            "com2",
            "com3",
            "com4",
            "com5",
            "com6",
            "com7",
            "com8",
            "com9",
            "com\u00b9",
            "com\u00b2",
            "com\u00b3",
            "lpt0",
            "lpt1",
            "lpt2",
            "lpt3",
            "lpt4",
            "lpt5",
            "lpt6",
            "lpt7",
            "lpt8",
            "lpt9",
            "lpt\u00b9",
            "lpt\u00b2",
            "lpt\u00b3"
        ],
        "mail_smtpsecure": "ssl",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***"
    }
}

Apps

The output of occ app:list (if possible).

Enabled:
  - bruteforcesettings: 6.0.0
  - calendar: 6.5.0
  - cloud_federation_api: 1.17.0
  - contacts: 8.7.2
  - dav: 1.36.0
  - dav_push: 1.0.1
  - federatedfilesharing: 1.23.0
  - files: 2.5.0
  - files_external: 1.25.1
  - files_pdfviewer: 6.0.0
  - files_sharing: 1.25.2
  - files_trashbin: 1.23.0
  - logreader: 6.0.0
  - lookup_server_connector: 1.21.0
  - memories: 8.0.1
  - music: 3.1.0
  - notifications: 6.0.0
  - notify_push: 1.3.3
  - oauth2: 1.21.0
  - password_policy: 5.0.0
  - photos: 6.0.0
  - previewgenerator: 5.13.0
  - profile: 1.2.0
  - provisioning_api: 1.23.0
  - richdocuments: 10.2.0
  - richdocumentscode_arm64: 26.4.104
  - serverinfo: 5.0.0
  - settings: 1.16.0
  - suspicious_login: 11.0.0
  - systemtags: 1.23.0
  - text: 7.0.1
  - theming: 2.8.0
  - theming_customcss: 1.20.0
  - twofactor_backupcodes: 1.22.0
  - twofactor_totp: 15.0.0
  - updatenotification: 1.23.0
  - user_migration: 10.3.0
  - viewer: 6.0.0
  - workflowengine: 2.15.0
Disabled:
  - activity: 6.0.0 (installed 4.0.0)
  - admin_audit: 1.23.0 (installed 1.21.0)
  - app_api: 33.0.0 (installed 5.0.2)
  - circles: 33.0.0 (installed 32.0.0)
  - comments: 1.23.0 (installed 1.21.0)
  - contactsinteraction: 1.14.1 (installed 1.12.0)
  - dashboard: 7.13.0 (installed 7.11.0)
  - encryption: 2.21.0 (installed 2.19.0)
  - federation: 1.23.0 (installed 1.21.0)
  - files_downloadlimit: 5.1.0 (installed 4.0.0)
  - files_reminders: 1.6.0 (installed 1.4.0)
  - files_versions: 1.26.0 (installed 1.24.0)
  - firstrunwizard: 6.0.0 (installed 4.0.0)
  - mail: 5.10.3 (installed 5.10.3)
  - nextcloud_announcements: 5.0.0 (installed 3.0.0)
  - privacy: 5.0.0 (installed 3.0.0)
  - recommendations: 6.0.0 (installed 4.0.0)
  - related_resources: 4.0.0 (installed 4.0.0-dev.0)
  - sharebymail: 1.23.0 (installed 1.21.0)
  - support: 5.0.0 (installed 3.0.0)
  - survey_client: 5.0.0 (installed 5.0.0-dev.0)
  - testing: 1.23.0
  - twofactor_nextcloud_notification: 7.0.0
  - user_ldap: 1.24.0
  - user_status: 1.13.0 (installed 1.11.0)
  - weather_status: 1.13.0 (installed 1.13.0)
  - webhook_listeners: 1.5.0 (installed 1.5.0)

Any ideas what i could do?

Yes, I’m facing the same problem on Nextcloud 32.0.12 and richdocuments version 9.1.0.

Seems to be a known bug:

So this seems to be fixed with richdocuments v11.0.0 which is already released in GitHub 2 weeks ago. But when i check with occ app:list, i see that im at richdocuments: 10.2.0 and occ app:update richdocuments gives me richdocuments is up-to-date or no updates could be found

Why is there no newer version?

Ahh ok, got it. v11.0.0 is only compatible with NC 34, but i got no Update Notification for my instance. Have now manually and git v11.0.0 for richdocuments. I will check later, if this solves the issue

Update to NC 34 was successful installed now. Richdocuments is on v11.00. But Memories and more important previewgenartor was not available for NC 34. After force activating Memories and Previewgenerator, the error is still there and not fixed.

Adding the suggested fix, fixes it manually.