server icon indicating copy to clipboard operation
server copied to clipboard

[Bug]: When uploading a file from browser or windows desktop app, it give following error getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given

Open fnaith opened this issue 2 years ago • 29 comments

⚠️ 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

My docker install of Nextcloud 26.0 with mysql was starting normally. Even bookmarks app works as expect. However when I upload file from browser or windows desktop app, it give following error :

[webdav] Error: TypeError: OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263 at <<closure>>

0. /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php line 263
   OCA\DAV\Upload\ChunkingV2Plugin->getUploadStorage(null)
1. /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
   OCA\DAV\Upload\ChunkingV2Plugin->beforeDelete(["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"])
2. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 456
   Sabre\DAV\Server->emit("beforeMethod:DELETE", [["Sabre\\HTTP\\ ... ]])
3. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 253
   Sabre\DAV\Server->invokeMethod(["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"])
4. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 321
   Sabre\DAV\Server->start()
5. /var/www/html/apps/dav/lib/Server.php line 366
   Sabre\DAV\Server->exec()
6. /var/www/html/apps/dav/appinfo/v2/remote.php line 35
   OCA\DAV\Server->exec()
7. /var/www/html/remote.php line 171
   require_once("/var/www/html/a ... p")

In help.nextcloud.com, a user suggest a solution by adding checkPrerequisites() call before calling getUploadStorage().

Steps to reproduce

  1. Create a CentOS 7(maybe by aws lightsail) and deploy Nextcloud 26 with docker compose.
  2. Login to Nextcloud as admin to finish initiation setup.
  3. Upload a file and check the error log.

Expected behavior

Upload file successfully.

Installation method

Community Docker image

Nextcloud Server version

26

Operating system

RHEL/CentOS

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?

  • [X] Default user-backend (database)
  • [ ] LDAP/ Active Directory
  • [ ] SSO - SAML
  • [ ] Other

Configuration report

{
    "system": {
        "htaccess.RewriteBase": "\/",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "apps_paths": [
            {
                "path": "\/var\/www\/html\/apps",
                "url": "\/apps",
                "writable": false
            },
            {
                "path": "\/var\/www\/html\/custom_apps",
                "url": "\/custom_apps",
                "writable": true
            }
        ],
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "drive.fnaith.com"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "26.0.0.11",
        "overwrite.cli.url": "http:\/\/drive.fnaith.com",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "overwriteprotocol": "https"
    }
}

List of activated Apps

nabled:
  - activity: 2.18.0
  - bookmarks: 13.0.1
  - circles: 26.0.0
  - cloud_federation_api: 1.9.0
  - dashboard: 7.6.0
  - dav: 1.25.0
  - federatedfilesharing: 1.16.0
  - files: 1.21.1
  - files_pdfviewer: 2.7.0
  - files_rightclick: 1.5.0
  - files_sharing: 1.18.0
  - files_trashbin: 1.16.0
  - files_versions: 1.19.1
  - firstrunwizard: 2.15.0
  - logreader: 2.11.0
  - lookup_server_connector: 1.14.0
  - nextcloud_announcements: 1.15.0
  - notifications: 2.14.0
  - oauth2: 1.14.0
  - password_policy: 1.16.0
  - photos: 2.2.0
  - privacy: 1.10.0
  - provisioning_api: 1.16.0
  - related_resources: 1.1.0-alpha1
  - serverinfo: 1.16.0
  - settings: 1.8.0
  - sharebymail: 1.16.0
  - support: 1.9.0
  - survey_client: 1.14.0
  - systemtags: 1.16.0
  - text: 3.7.2
  - theming: 2.1.1
  - twofactor_backupcodes: 1.15.0
  - updatenotification: 1.16.0
  - viewer: 1.10.0
  - workflowengine: 2.8.0
Disabled:
  - admin_audit: 1.16.0
  - bruteforcesettings: 2.6.0
  - comments: 1.16.0 (installed 1.16.0)
  - contactsinteraction: 1.7.0 (installed 1.7.0)
  - encryption: 2.14.0
  - federation: 1.16.0 (installed 1.16.0)
  - files_external: 1.18.0
  - recommendations: 1.5.0 (installed 1.5.0)
  - suspicious_login: 4.4.0
  - twofactor_totp: 8.0.0-alpha.0
  - user_ldap: 1.16.0
  - user_status: 1.6.0 (installed 1.6.0)
  - weather_status: 1.6.0 (installed 1.6.0)

Nextcloud Signing status

No errors have been found.

Nextcloud Logs

[webdav] Error: TypeError: OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263 at <<closure>>

0. /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php line 263
   OCA\DAV\Upload\ChunkingV2Plugin->getUploadStorage(null)
1. /var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
   OCA\DAV\Upload\ChunkingV2Plugin->beforeDelete(["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"])
2. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 456
   Sabre\DAV\Server->emit("beforeMethod:DELETE", [["Sabre\\HTTP\\ ... ]])
3. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 253
   Sabre\DAV\Server->invokeMethod(["Sabre\\HTTP\\Request"], ["Sabre\\HTTP\\Response"])
4. /var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php line 321
   Sabre\DAV\Server->start()
5. /var/www/html/apps/dav/lib/Server.php line 366
   Sabre\DAV\Server->exec()
6. /var/www/html/apps/dav/appinfo/v2/remote.php line 35
   OCA\DAV\Server->exec()
7. /var/www/html/remote.php line 171
   require_once("/var/www/html/a ... p")

DELETE /remote.php/dav/uploads/fnaith/3925943308
from 36.225.143.72 by fnaith at 2023-04-04T16:48:25+00:00

Additional info

docker-compose.yml :

version: "3"
services:
  nextcloud:
    image: nextcloud:26.0.0-apache
    restart: always
    ports:
      - 9009:80
    volumes:
      - ./data:/var/www/html
    environment:
      - MYSQL_PASSWORD=a_pwd
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=a_user
      - MYSQL_HOST=a_db.com

fnaith avatar Apr 05 '23 00:04 fnaith

Hey @fnaith , what is the size of the files that you are trying to upload?

MiguelNdeCarvalho avatar Apr 06 '23 09:04 MiguelNdeCarvalho

2.9 MB ...

And then I don't even try to upload anything. Because I just assume any file uploading can't be done.

BTW, I don't set email, webdav server and disable many apps. Don't know the root cause of this issue.

fnaith avatar Apr 06 '23 09:04 fnaith

I asked the size, because it was only occurring for me with bigger files. But yha this a critical bug, as this breaks the main functionality of Nextcloud

MiguelNdeCarvalho avatar Apr 06 '23 17:04 MiguelNdeCarvalho

Same thing happens to me with docker-compose mariadb container and nextcloud container. Cant upload files over the browser.

MrDarkPat avatar Apr 06 '23 23:04 MrDarkPat

Same thing happens to me with docker-compose mariadb container and nextcloud container. Cant upload files over the browser.

If you are experiencing the same please upvote the issue, so we can show that more people is getting the same problem as us!

MiguelNdeCarvalho avatar Apr 07 '23 00:04 MiguelNdeCarvalho

Yay, and maybe more people can collect enough data for this issue.

fnaith avatar Apr 07 '23 02:04 fnaith

I've been attempting to reproduce this. I was about to give up and gather a bit more information then I thought to try one more thing: And I managed to trigger this issue.

If I set a quota and the upload manages to hit up against it it occurs.

Do either of you have a user quota (in nextcloud) on your respective accounts? Or possibly other reasons to be hitting disk space limitations on the server?

Keep in mind that uploads require more space temporarily so it may be getting triggered even if you think your upload is within your storage limits.

joshtrichards avatar Apr 07 '23 12:04 joshtrichards

I set 5GB per user.

fnaith avatar Apr 07 '23 13:04 fnaith

And what is your current quota utilization? And, for completeness, do you have plenty of storage space available on the underlying server itself?

Also, in your nextcloud logs, what is the entry immediately proceeding the entry for the getUploadStorage() error? (either from nextcloud.log or from Administration settings->Logging in the Web interface)?

joshtrichards avatar Apr 07 '23 13:04 joshtrichards

log : log

quota : quota

[PHP] Error: Undefined array key "mail_smtpauthtype" at /var/www/html/apps/settings/templates/settings/admin/additional-mail.php#132

GET /settings/admin
from 36.225.108.244 by fnaith at 2023-04-07T14:19:10+00:00

fnaith avatar Apr 07 '23 14:04 fnaith

My problem was fixxed because of the proxy container client_max_body_size was too little. I got into the /home/user/nextcloud/proxy/conf.d there is a file called default.conf I added to the bottom client_max_body_size 5000m; after this I reloaded nginx and "sudo docker exex "ContainerName" nginx -s reload" and it fixxed my problem. Dont forget to modify in the docker-compose file the envirnoment variable: PHP_UPLOAD_LIMIT="Your Limit"

MrDarkPat avatar Apr 07 '23 19:04 MrDarkPat

Thanks you @MrDarkPat 🥇

My problem is solved, after adding client_max_body_size 1G; in my nginx.conf .

@joshtrichards Sorry for my careless setting. 🙇

@MiguelNdeCarvalho could you also try this approach ?

fnaith avatar Apr 08 '23 10:04 fnaith

Whats the apoppriate setting for apache2 configurations? Seems like I am missing something.

MishoManolov avatar Apr 10 '23 06:04 MishoManolov

I have the same issue, just did a fresh installation and getting this error. I have added under environment max size limits and also mapped .conf file with upload size limit but it makes no difference. Can someone please help or should I downgrade to v25?

vincentkenny01 avatar Apr 11 '23 19:04 vincentkenny01

@vincentkenny01 maybe you can give more information to maintainer ?

fnaith avatar Apr 12 '23 01:04 fnaith

here is the error log which looks like the same as above. {"reqId":"pmoyihLF5z84CArptLdW","level":3,"time":"2023-04-12T12:14:25+00:00","remoteAddr":"85.89.187.99","user":"vp","app":"webdav","method":"DELETE","url":"/remote.php/dav/uploads/vp/web-file-upload-7527ba7ca898082f86c85e47f260fb69-1681301664831","message":"OCA\\DAV\\Upload\\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15","version":"26.0.0.11","exception":{"Exception":"TypeError","Message":"OCA\\DAV\\Upload\\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263","Code":0,"Trace":[{"file":"/var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php","line":263,"function":"getUploadStorage","class":"OCA\\DAV\\Upload\\ChunkingV2Plugin","type":"->","args":[null]},{"file":"/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"beforeDelete","class":"OCA\\DAV\\Upload\\ChunkingV2Plugin","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":456,"function":"emit","class":"Sabre\\DAV\\Server","type":"->","args":["beforeMethod:DELETE",[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[["Sabre\\HTTP\\Request"],["Sabre\\HTTP\\Response"]]},{"file":"/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/lib/Server.php","line":366,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->","args":[]},{"file":"/var/www/html/remote.php","line":171,"args":["/var/www/html/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php","Line":294,"message":"OCA\\DAV\\Upload\\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263","exception":[],"CustomMessage":"OCA\\DAV\\Upload\\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/html/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263"},"id":"6436a0d721111"}

vincentkenny01 avatar Apr 12 '23 12:04 vincentkenny01

Whats the apoppriate setting for apache2 configurations? Seems like I am missing something.

There is no limit there.

Do you use the Docker version?. Maybe the issue is there.

EchedelleLR avatar Apr 16 '23 13:04 EchedelleLR

Hi It’s fixed now. Not sure why I had this error but I did a fresh install and it’s all working again.

On 16 Apr 2023, at 14:01, EchedeyLR @.***> wrote:



Whats the apoppriate setting for apache2 configurations? Seems like I am missing something.

There is no limit there.

Do you use the Docker version? Maybe the issue is there.

— Reply to this email directly, view it on GitHubhttps://github.com/nextcloud/server/issues/37578#issuecomment-1510375770, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACGKX2U4C4FHXFK5KVOM3WLXBPUUHANCNFSM6AAAAAAWTM26K4. You are receiving this because you were mentioned.Message ID: @.***>

vincentkenny01 avatar Apr 16 '23 13:04 vincentkenny01

A fresh install is not a proper solution for the issue. Here I have a lot of information in a multiuser environment and that would break everything.

I am using a raw installation with Apache2.

I think that the issue is in Nextcloud 26 since I have the same configurations in another host for Nextcloud 25 and this doesn't happen.

EchedelleLR avatar Apr 16 '23 13:04 EchedelleLR

New information: Neither Nextcloud desktop app nor Android app have this issue. Just the web browser client.

EchedelleLR avatar Apr 17 '23 19:04 EchedelleLR

I have this error as well, and the problem that i cannot cancel the upload and need to reload the tab that it cancels a file upload. this happens only in NC26.

LPDaVinci avatar Apr 20 '23 21:04 LPDaVinci

I got the same issue but I noticed that on the reverse proxy (nginx) there was no space left (at a first glance it still did look alright - i noticed it because i wanted to do a restart from nginx after setting this: client_max_body_size 1G; it was before set to 0

MrColumbo avatar Apr 23 '23 18:04 MrColumbo

This issue still exists in 26.0.1.

hoekomnie avatar Apr 28 '23 16:04 hoekomnie

Just faced the same problem. Didn't have to upload any big file for quite a while, until today. I know, it used to work and my PHP installation didn't change, but I upgraded my Nextcloud several times since last big file upload. I disabled Cloudflare just to rule it out. No joy either desktop client or web, just TypeError: OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given, called in /var/www/nextcloud/apps/dav/lib/Upload/ChunkingV2Plugin.php on line 263. My setup is plain Apache2 with PHP8.1-FPM. Already applied mods from admin manual

Nextcloud 26.0.1

PHP: Version: 8.1.2 Memory limit: 4 GB Max execution time: 3600 Upload max size: 16 GB Extensions: Core, date, libxml, openssl, pcre, zlib, filter, hash, json, Reflection, SPL, session, standard, sodium, cgi-fcgi, PDO, xml, apcu, bcmath, bz2, calendar, ctype, curl, dom, mbstring, FFI, fileinfo, ftp, gd, gettext, gmp, iconv, igbinary, imagick, intl, exif, memcache, pdo_pgsql, pgsql, Phar, posix, readline, redis, shmop, SimpleXML, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xmlreader, xmlwriter, xsl, zip, Zend OPcache

DB: Type: pgsql Version: PostgreSQL 14.7 (Ubuntu 14.7-0ubuntu0.22.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0, 64-bit Size: 1.9 GB

adi-dev avatar Apr 30 '23 21:04 adi-dev

In comparison with some other people here using Nginx as frontend (mostly reserve proxy), we both share the same issue @adi-dev.

EchedelleLR avatar Apr 30 '23 21:04 EchedelleLR

Btw a tip, memory limit and post size must be always higher than upload filesize.

Also, having the upload filesize limited to 32 or 64 MiB in versions 25 and before didn't affect to the uploading of big files because Nextcloud perform chunking, which is currently failing.

EchedelleLR avatar Apr 30 '23 22:04 EchedelleLR

Btw a tip, memory limit and post size must be always higher than upload filesize.

Also, having the upload filesize limited to 32 or 64 MiB in versions 25 and before didn't affect to the uploading of big files because Nextcloud perform chunking, which is currently failing.

Fixing memory limit, post size and upload filesize didn't make any difference.

adi-dev avatar Apr 30 '23 22:04 adi-dev

Faced the same issue. When I upload a directory containing files only files less than 10Mb are uploaded. Upload filesize and memory limit tweaked in both php and nginx. The exception is

OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage(): Argument #1 ($targetPath) must be of type string, null given

Nextcloud was installed today. Maybe the reason is related with the storage. I use external S3 as default one. S3 is not mounted by OS, it is connected as nextcloud external storage. Nginx, php8.0. Nextcloud Hub 4 (26.0.1), non-Docker environment. PS. Checked the size of files. 9.9Mb uploads successfully, 10.01Mb gives an error PPS. https://help.nextcloud.com/t/nextcloud-13-chunking-upload-not-working/28755/17 fixed this error for me

Shenter avatar May 03 '23 10:05 Shenter

Hi all, I notice same issue in some of my instances (26.0.1( when I try to "cancel" an upload or backend try to delete something on upload. OCA\DAV\Upload\ChunkingV2Plugin::getUploadStorage(): Argument https://github.com/nextcloud/server/issues/1 ($targetPath) must be of type string, null given

I found a "bug" on the ChunkingV2Plugin and I will try to create a PR to fix it. Hoping central team will approve it.

tanganellilore avatar May 04 '23 14:05 tanganellilore

Hi everyone. I was experiencing the same problem when uploading things bigger than 40MB. My nextcloud instance is running with docker-compose and behind nginx proxy manager, I have increased php file upload size, memory size, etc. I tried many things in the NPM but the only thing that worked for me was by setting this proxy_request_buffering off;

Hopefully this will help someone.

juanyunis avatar May 05 '23 03:05 juanyunis