nextcloud / nextcloud/server

Files scan fails on filenames with invalid UTF-8 characters

Open
#59,056 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage 33-feedback bug feature: filesystem feature: occ hotspot: filename handling
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

⚠️ This issue respects the following points: ⚠️
Bug description

Been running a few occ files:scan --all after moving a bunch of files, moved files and folders in stages, previously it worked, now when i moved the last folders with files, i get this error thrown

Exception during scan: An exception occurred while executing a query: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect string value: '\xF1o cor...' for column `squid`.`oc_filecache`.`name` at row 1
#0 /app/www/public/lib/private/DB/ConnectionAdapter.php(69): OC\DB\Exceptions\DbalException::wrap()
#1 /app/www/public/lib/private/DB/QueryBuilder/QueryBuilder.php(285): OC\DB\ConnectionAdapter->executeStatement()
#2 /app/www/public/lib/private/Files/Cache/Cache.php(305): OC\DB\QueryBuilder\QueryBuilder->executeStatement()
#3 /app/www/public/lib/private/Files/Cache/Scanner.php(276): OC\Files\Cache\Cache->insert()
#4 /app/www/public/lib/private/Files/Cache/Scanner.php(227): OC\Files\Cache\Scanner->addToCache()
#5 /app/www/public/lib/private/Files/Cache/Scanner.php(489): OC\Files\Cache\Scanner->scanFile()
#6 /app/www/public/lib/private/Files/Cache/Scanner.php(413): OC\Files\Cache\Scanner->handleChildren()
#7 /app/www/public/lib/private/Files/Cache/Scanner.php(418): OC\Files\Cache\Scanner->scanChildren()
#8 /app/www/public/lib/private/Files/Cache/Scanner.php(418): OC\Files\Cache\Scanner->scanChildren()
#9 /app/www/public/lib/private/Files/Cache/Scanner.php(418): OC\Files\Cache\Scanner->scanChildren()
#10 /app/www/public/lib/private/Files/Cache/Scanner.php(322): OC\Files\Cache\Scanner->scanChildren()
#11 /app/www/public/lib/private/Files/Utils/Scanner.php(246): OC\Files\Cache\Scanner->scan()
#12 /config/www/nextcloud/apps/files/lib/Command/Scan.php(165): OC\Files\Utils\Scanner->scan()
#13 /config/www/nextcloud/apps/files/lib/Command/Scan.php(255): OCA\Files\Command\Scan->scanFiles()
#14 /app/www/public/3rdparty/symfony/console/Command/Command.php(326): OCA\Files\Command\Scan->execute()
#15 /app/www/public/core/Command/Base.php(220): Symfony\Component\Console\Command\Command->run()
#16 /app/www/public/3rdparty/symfony/console/Application.php(1078): OC\Core\Command\Base->run()
#17 /app/www/public/3rdparty/symfony/console/Application.php(324): Symfony\Component\Console\Application->doRunCommand()
#18 /app/www/public/3rdparty/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun()
#19 /app/www/public/lib/private/Console/Application.php(187): Symfony\Component\Console\Application->run()
#20 /app/www/public/console.php(92): OC\Console\Application->run()
#21 /app/www/public/occ(33): require_once('...')
#22 {main}

Docker compose

services:
  nextcloud:
    image: lscr.io/linuxserver/nextcloud:latest
    container_name: nextcloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Stockholm
    volumes:
      - /docker/nextcloud/config:/config
      - /data/nextcloud_data:/data
    ports:
      - 6443:443
    restart: unless-stopped

  redis:
    image: redis:alpine
    restart: always
    command: redis-server --requirepass <password>

Steps to reproduce
Expected behavior

no error

Nextcloud Server version

33

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.4

Web server

Other

Database engine version

MySQL

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

None

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": {
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "filer.gubbe.org"
        ],
        "dbtype": "mysql",
        "version": "33.0.0.16",
        "overwrite.cli.url": "https:\/\/filer.gubbe.org",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_smtpsecure": "ssl",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauth": true,
        "mail_smtpport": "465",
        "mail_sendmailmode": "smtp",
        "mail_smtpstreamoptions": {
            "ssl": {
                "allow_self_signed": false,
                "verify_peer": true,
                "verify_peer_name": true
            }
        },
        "maintenance": false,
        "memcache.local": "\\OC\\Memcache\\Redis",
        "filelocking.enabled": true,
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "timeout": 0,
            "password": "***REMOVED SENSITIVE VALUE***"
        },
        "maintenance_window_start": 1,
        "upgrade.disable-web": true
    }
}
List of activated Apps
Enabled:
  - activity: 6.0.0-dev.0
  - admin_audit: 1.23.0
  - bookmarks: 16.1.3
  - bruteforcesettings: 6.0.0-dev.0
  - calendar: 6.2.1
  - checksum: 2.0.3
  - circles: 33.0.0
  - cloud_federation_api: 1.17.0
  - comments: 1.23.0
  - contacts: 8.4.1
  - contactsinteraction: 1.14.1
  - dashboard: 7.13.0
  - dav: 1.36.0
  - federatedfilesharing: 1.23.0
  - federation: 1.23.0
  - files: 2.5.0
  - files_accesscontrol: 4.0.0
  - files_downloadlimit: 5.1.0-dev.0
  - files_pdfviewer: 6.0.0-dev.0
  - files_reminders: 1.6.0
  - files_sharing: 1.25.2
  - files_trashbin: 1.23.0
  - files_versions: 1.26.0
  - firstrunwizard: 6.0.0-dev.0
  - logreader: 6.0.0
  - lookup_server_connector: 1.21.0
  - mail: 5.7.3
  - nextcloud_announcements: 5.0.0
  - notes: 4.13.0
  - notifications: 6.0.0
  - oauth2: 1.21.0
  - password_policy: 5.0.0-dev.0
  - photos: 6.0.0-dev.0
  - privacy: 5.0.0-dev.0
  - profile: 1.2.0
  - provisioning_api: 1.23.0
  - related_resources: 4.0.0-dev.0
  - richdocuments: 10.1.0
  - serverinfo: 5.0.0-dev.0
  - settings: 1.16.0
  - sharebymail: 1.23.0
  - support: 5.0.0
  - survey_client: 5.0.0-dev.0
  - systemtags: 1.23.0
  - text: 7.0.0-dev.3
  - theming: 2.8.0
  - theming_customcss: 1.20.0
  - twofactor_backupcodes: 1.22.0
  - twofactor_totp: 15.0.0-dev.0
  - updatenotification: 1.23.0
  - user_status: 1.13.0
  - viewer: 6.0.0-dev.0
  - weather_status: 1.13.0
  - webhook_listeners: 1.5.0
  - workflowengine: 2.15.0
Disabled:
  - app_api: 33.0.0 (installed 33.0.0)
  - encryption: 2.21.0
  - files_antivirus: 6.2.0 (installed 6.2.0)
  - files_external: 1.25.1
  - recommendations: 6.0.0-dev.0 (installed 6.0.0-dev.0)
  - spreed: 23.0.1 (installed 23.0.1)
  - suspicious_login: 11.0.0-dev.0
  - twofactor_nextcloud_notification: 7.0.0
  - user_ldap: 1.24.0
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
{"reqId":"6FIbveaKBEQzqwBvanRS","level":2,"time":"2026-03-18T19:07:42+00:00","remoteAddr":"","user":"--","app":"core","method":"","url":"--","scriptName":"/app/www/public/occ","message":"normalizing failed for \"files/<user_folder>/<filename that have ? in it>\"","userAgent":"--","version":"33.0.0.16","occ_command":["/app/www/public/occ","files:scan"],"data":{"app":"core"},"id":"69baf807e0471"}


Filenames also seems to have characters like this in it 'thefilename'$'\217''_08.avi.jpg'
Additional info

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/private/Files/Cache/Scanner.php and lib/private/Files/Cache/Cache.php, following the files:scan entry point in apps/files/lib/Command/Scan.php. Reproduce the failure with filenames containing invalid UTF-8 or the characters noted in the logs, then trace the normalization and database insert path. Done means occ files:scan completes without failing and affected filenames are handled consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, php
Domain
backend, cli, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.