Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to set .0 through .9 as mimetypemapping.json #42902

Closed
5 of 8 tasks
e46lux opened this issue Jan 17, 2024 · 2 comments · Fixed by #50660
Closed
5 of 8 tasks

[Bug]: Unable to set .0 through .9 as mimetypemapping.json #42902

e46lux opened this issue Jan 17, 2024 · 2 comments · Fixed by #50660
Assignees

Comments

@e46lux
Copy link

e46lux commented Jan 17, 2024

⚠️ This issue respects the following points: ⚠️

Bug description

Setting mimetypemapping.json to the following:

{
        "0" : ["text/plain"],
        "1" : ["text/plain"],
        "2" : ["text/plain"],
        "3" : ["text/plain"],
        "4" : ["text/plain"],
        "5" : ["text/plain"],
        "6" : ["text/plain"],
        "7" : ["text/plain"],
        "8" : ["text/plain"],
        "9" : ["text/plain"],
        "bak" : ["text/plain"],
        "log" : ["text/plain"],
        "ps1" : ["text/plain"],
        "sql" : ["text/plain"]
}

breaks mime type loader with an error:

TypeError: str_starts_with(): Argument #1 ($haystack) must be of type string, int given in /var/www/nextcloud/lib/private/Files/Type/Detection.php:119

As soon as you remove the rows "0" through "9" it works fine.
Would be nice to view filenames that end in a number in the text viewer for browsing nginx logs for example.
Cheers~

Steps to reproduce

  1. Add above codeblock to mimetypemapping.json
  2. Reboot nextcloud
  3. Try to browse an SMB share external storage (not sure if you get same error with local storage). Able to see the external storage in Home folder, but clicking the share shows 0 files in web UI. Still able to access files via share links, etc, so things appear to work fine outside of being able to list directory contents.

Expected behavior

Would like the ".0" file to open in text editor.

Installation method

Community Web installer on a VPS or web space

Nextcloud Server version

28

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MySQL

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": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_X_FORWARDED",
            "HTTP_FORWARDED_FOR",
            "HTTP_X_REAL_IP"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "28.0.1.1",
        "overwrite.cli.url": "https:\/\/***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https",
        "overwritehost": "***REMOVED SENSITIVE VALUE***",
        "preview_max_memory": 5120,
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.local": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0
        },
        "filelocking.enabled": true,
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "default_phone_region": "US",
        "enable_previews": true,
        "preview_max_x": 512,
        "preview_max_y": 512,
        "preview_max_filesize_image": 250,
        "jpeg_quality": "60",
        "enabledPreviewProviders": [
            "OC\\Preview\\Movie",
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\BMP",
            "OC\\Preview\\XBitmap",
            "OC\\Preview\\MP3",
            "OC\\Preview\\MP4",
            "OC\\Preview\\TXT",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\PDF"
        ],
        "app_install_overwrite": [
            "fulltextsearch",
            "fulltextsearch_elasticsearch",
            "files_fulltextsearch",
            "files_fulltextsearch_tesseract",
            "checksum",
            "breezedark",
            "video_converter",
            "carnet",
            "camerarawpreviews",
            "flowupload"
        ],
        "updater.release.channel": "beta"
    }
}

List of activated Apps

Enabled:
  - activity: 2.20.0
  - admin_audit: 1.18.0
  - bruteforcesettings: 2.8.0
  - checksum: 1.2.3
  - circles: 28.0.0-dev
  - cloud_federation_api: 1.11.0
  - comments: 1.18.0
  - contactsinteraction: 1.9.0
  - dav: 1.29.1
  - federatedfilesharing: 1.18.0
  - federation: 1.18.0
  - files: 2.0.0
  - files_external: 1.20.0
  - files_pdfviewer: 2.9.0
  - files_reminders: 1.1.0
  - files_sharing: 1.20.0
  - files_trashbin: 1.18.0
  - files_versions: 1.21.0
  - firstrunwizard: 2.17.0
  - impersonate: 1.15.0
  - logreader: 2.13.0
  - lookup_server_connector: 1.16.0
  - nextcloud_announcements: 1.17.0
  - notes: 4.9.2
  - notifications: 2.16.0
  - oauth2: 1.16.3
  - password_policy: 1.18.0
  - photos: 2.4.0
  - previewgenerator: 5.4.0
  - privacy: 1.12.0
  - provisioning_api: 1.18.0
  - recommendations: 2.0.0
  - related_resources: 1.3.0
  - serverinfo: 1.18.0
  - settings: 1.10.1
  - sharebymail: 1.18.0
  - support: 1.11.0
  - survey_client: 1.16.0
  - suspicious_login: 6.0.0
  - systemtags: 1.18.0
  - text: 3.9.1
  - theming: 2.3.0
  - theming_customcss: 1.15.0
  - twofactor_backupcodes: 1.17.0
  - twofactor_totp: 10.0.0-beta.2
  - updatenotification: 1.18.0
  - user_status: 1.8.1
  - viewer: 2.2.0
  - workflowengine: 2.10.0
Disabled:
  - camerarawpreviews: 0.8.4 (installed 0.8.4)
  - dashboard: 7.8.0 (installed 7.7.0)
  - drawio: 3.0.2 (installed 3.0.2)
  - emlviewer: 1.0.8 (installed 1.0.8)
  - encryption: 2.16.0
  - files_rightclick: 0.15.1 (installed 1.6.0)
  - metadata: 0.19.0 (installed 0.19.0)
  - user_ldap: 1.19.0
  - weather_status: 1.8.0 (installed 1.7.0)

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

{"reqId":"ysWzWbl6FJXhZdDFC88w","level":3,"time":"2024-01-17T22:17:07+00:00","remoteAddr":"***REMOVED SENSITIVE VALUE***","user":"admin","app":"webdav","method":"PROPFIND","url":"/remote.php/dav/files/***REMOVED SENSITIVE VALUE***","message":"str_starts_with(): Argument #1 ($haystack) must be of type string, int given","userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","version":"28.0.1.1","exception":{"Exception":"TypeError","Message":"str_starts_with(): Argument #1 ($haystack) must be of type string, int given","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Type/Detection.php","line":119,"function":"str_starts_with"},{"file":"/var/www/nextcloud/lib/private/Files/Type/Detection.php","line":178,"function":"registerTypeArray","class":"OC\\Files\\Type\\Detection","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Type/Detection.php","line":196,"function":"loadMappings","class":"OC\\Files\\Type\\Detection","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php","line":617,"function":"detectPath","class":"OC\\Files\\Type\\Detection","type":"->"},{"file":"/var/www/nextcloud/apps/files_external/lib/Lib/Storage/SMB.php","line":652,"function":"getMetaDataFromFileInfo","class":"OCA\\Files_External\\Lib\\Storage\\SMB","type":"->"},{"function":"getDirectoryContent","class":"OCA\\Files_External\\Lib\\Storage\\SMB","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Scanner.php","line":427,"function":"iterator_to_array"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Scanner.php","line":397,"function":"handleChildren","class":"OC\\Files\\Cache\\Scanner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Scanner.php","line":347,"function":"scanChildren","class":"OC\\Files\\Cache\\Scanner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1335,"function":"scan","class":"OC\\Files\\Cache\\Scanner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1374,"function":"getCacheEntry","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":215,"function":"getFileInfo","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":83,"function":"getChild","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":971,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1662,"function":"getPropertiesIteratorForPath","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1647,"function":"writeMultiStatus","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":346,"function":"generateMultiStatus","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPropFind","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":370,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":172,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/Files/Type/Detection.php","Line":119,"message":"str_starts_with(): Argument #1 ($haystack) must be of type string, int given","exception":[],"CustomMessage":"str_starts_with(): Argument #1 ($haystack) must be of type string, int given"},"id":"65a8580aa7315"}
Error	jsresourceloader	
Could not find resource files_external/js/public_key.js to load

2024-01-17T22:17:20+00:00	

Error	jsresourceloader	
Could not find resource files_external/js/oauth2.js to load

2024-01-17T22:17:20+00:00	

Error	jsresourceloader	
Could not find resource files_external/js/oauth1.js to load

2024-01-17T22:17:20+00:00	

Error	webdav	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given

2024-01-17T22:17:07+00:00	

Error	webdav	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given

2024-01-17T22:16:59+00:00	

Error	webdav	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given

2024-01-17T22:16:56+00:00	

Error	core	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given
Error while running background job (class: OCA\Files\BackgroundJob\ScanFiles, arguments: )

2024-01-17T22:15:02+00:00	

Error	webdav	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given

2024-01-17T22:08:09+00:00	

Error	core	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given
Error while running background job (class: OCA\Files\BackgroundJob\ScanFiles, arguments: )

2024-01-17T22:00:02+00:00	

Error	webdav	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given

2024-01-17T21:53:06+00:00	

Error	webdav	
TypeError
str_starts_with(): Argument #1 ($haystack) must be of type string, int given

2024-01-17T21:52:56+00:00	

Error	cron	
Exception
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory
Exception thrown: Doctrine\DBAL\Exception

2024-01-17T21:52:35+00:00	

Error	core	
Exception
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory
Error while running background job (class: OC\Core\BackgroundJobs\GenerateMetadataJob, arguments: )

2024-01-17T21:52:35+00:00	

Warning	no app in context	
DbalException
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory
Error while generating metadata for fileid 1097678

2024-01-17T21:52:35+00:00	

Warning	no app in context	
DbalException
Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory
exception while getMetadataFromDatabase()

2024-01-17T21:52:35+00:00

Additional info

No response

@e46lux e46lux added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jan 17, 2024
@joshtrichards
Copy link
Member

PHP's json_decode() automatically converts those particular entries to integers internally when using them as keys for the target array (despite being quoted).

Unfortunately, since it happens internally (and when the keys are established), it's not a simple matter of casting ourselves before use. 🤔

@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Feb 5, 2025
@skjnldsv
Copy link
Member

skjnldsv commented Feb 5, 2025

#50660

@skjnldsv skjnldsv self-assigned this Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants