BadRequest Expected filesize -- caused by .pending files on Pixel Phone?

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 28.0.5 NextcloudPi
Operating system and version: Armbian 24.5.1 bookworm
Apache or nginx version: Apache 2.4.61-1~deb12u1
PHP version (eg, 8.3): 8.3.9-1+0~20240708.36+debian12~1.gbp429c36

The issue you are facing:

I have a Pixel phone and the camera seems to create files starting with .pending while it’s processing. NextCloud auto upload tries to upload these files immediately after they’re created so then there are upload entries to clean up.

I also have intermittent messages in the logs along this pattern:

BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1507328 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.

I suspect this has to do with the client starting to upload the .pending file, which is then deleted by the phone.

Is there a way to force it so that certain file names don’t upload as part of auto upload or some other way to avoid this issue?

Is this the first time you’ve seen this error? (Y/N): N

Steps to replicate it:

  1. Enable auto-upload for photos
  2. Take a picture on the phone
  3. Check the logs

The output of your Nextcloud log in Admin > Logging:

Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1507328 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 11:24:38 AM 	
Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1064960 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 10:01:51 AM 	
Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1015808 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 9:45:53 AM 	
Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 638976 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 9:29:33 AM 	
Warning	no app in context	
LockedException "GISdat/proj/270/lab2/Lab 2 Bond James Bond_index" is locked, existing lock on file: none
issue while running MetadataUpdate
Jul 11, 2024, 3:43:47 AM 	
Warning	core	
Login failed: 'afiiskc' (Remote IP: '46.105.97.78')
Jul 8, 2024, 9:44:58 PM 	
Error	webdav	
DeadlockException An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
Jul 8, 2024, 5:18:54 PM 	
Error	webdav	
DeadlockException An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
Jul 8, 2024, 5:18:54 PM 	
Warning	no app in context	
LockedException "GISdat/proj/270/lab2" is locked, existing lock on file: none
issue while running MetadataUpdate
Jul 7, 2024, 4:32:47 PM 	
Warning	no app in context	
LockedException "GISdat/proj" is locked, existing lock on file: none
issue while running MetadataUpdate
Jul 7, 2024, 2:32:47 PM 	
Error	no app in context	
The X-File-MD5 header must not be null.
Jul 7, 2024, 2:14:27 PM 	
Error	no app in context	
BadRequest Expected filesize of 2133584 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 663552 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 5, 2024, 2:16:27 PM 	
Warning	core	
Login failed: 'Q4QWG' (Remote IP: '87.246.7.194')
Jun 30, 2024, 10:44:03 AM 	
Warning	core	
Login failed: 'Q4QWG' (Remote IP: '87.246.7.194')
Jun 30, 2024, 10:44:01 AM 	
Warning	no app in context	
LockedException "GISdat/proj/270/lab2/Lab 2 Bond James Bond_index" is locked, existing lock on file: none
issue while running MetadataUpdate
Jun 25, 2024, 12:34:27 PM 	
Error	PHP	
TypeError: OCA\Files_Sharing\Controller\ShareesAPIController::__construct(): Argument #3 ($userId) must be of type string, null given at /var/www/nextcloud/apps/files_sharing/lib/Controller/ShareesAPIController.php#106
Jun 23, 2024, 7:06:28 PM 	
Error	core	
InvalidTokenException Token does not exist: 857a68d5ccbc18ebd09857b616206824ecb03b1c5679e6d71232f3528240372b4e9c6e19ff3396711e6fde714d9801c2e9aa0bfa39ff9c2388f5dcabd37f3bdb
Renewing session token failed: Token does not exist: 857a68d5ccbc18ebd09857b616206824ecb03b1c5679e6d71232f3528240372b4e9c6e19ff3396711e6fde714d9801c2e9aa0bfa39ff9c2388f5dcabd37f3bdb
Jun 23, 2024, 7:06:23 PM 	
Warning	core	
Login failed: '0x59b114d294ffd20c56453acd1329a17593e660c2' (Remote IP: '185.91.69.110')
Jun 21, 2024, 8:24:52 PM 	
Warning	core	
Login failed: '17LstBVHRzWdobGpTP1gZ1k23u1gfN7zTr' (Remote IP: '185.91.69.110')
Jun 21, 2024, 8:24:48 PM 	
Warning	core	
Login failed: 'afiiskc' (Remote IP: '154.26.132.60')
Jun 20, 2024, 6:21:48 PM 

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

will paste if requested

The output of your Apache/nginx/system log in /var/log/____:

error.log:

[Fri Jul 12 00:00:08.520437 2024] [mpm_event:notice] [pid 1239:tid 281473719963680] AH00489: Apache/2.4.59 (Debian) OpenSSL/3.0.11 configured -- resuming normal operations
[Fri Jul 12 00:00:08.520521 2024] [core:notice] [pid 1239:tid 281473719963680] AH00094: Command line: '/usr/sbin/apache2'
[Fri Jul 12 06:07:16.293815 2024] [mpm_event:notice] [pid 1239:tid 281473719963680] AH00492: caught SIGWINCH, shutting down gracefully
[Fri Jul 12 06:07:16.415144 2024] [ssl:warn] [pid 2256961:tid 2256961] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Fri Jul 12 06:07:16.454565 2024] [ssl:warn] [pid 2256962:tid 2256962] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the server name
[Fri Jul 12 06:07:16.471400 2024] [mpm_event:notice] [pid 2256962:tid 2256962] AH00489: Apache/2.4.61 (Debian) OpenSSL/3.0.13 configured -- resuming normal operations
[Fri Jul 12 06:07:16.471517 2024] [core:notice] [pid 2256962:tid 2256962] AH00094: Command line: '/usr/sbin/apache2'

nc-error.log:
[Fri Jul 12 01:05:33.153616 2024] [core:error] [pid 2212499:tid 281473480180000] [client 116.255.137.231:46290] AH10244: invalid URI path (/cgi-bin/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/bin/sh)
[Fri Jul 12 01:05:34.637000 2024] [core:error] [pid 2212499:tid 281473463271712] [client 116.255.137.231:46668] AH10244: invalid URI path (/cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/bin/sh)

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

# These are also posted above
Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1507328 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 11:24:38 AM 	
Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1064960 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 10:01:51 AM 	
Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1015808 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 9:45:53 AM 	
Error	no app in context	
BadRequest Expected filesize of 2699864 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 638976 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 11, 2024, 9:29:33 AM 	
Error	webdav	
DeadlockException An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
Jul 8, 2024, 5:18:54 PM 	
Error	webdav	
DeadlockException An exception occurred while executing a query: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction
Jul 8, 2024, 5:18:54 PM 	
Error	no app in context	
The X-File-MD5 header must not be null.
Jul 7, 2024, 2:14:27 PM 	
Error	no app in context	
BadRequest Expected filesize of 2133584 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 663552 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jul 5, 2024, 2:16:27 PM 	
Error	PHP	
TypeError: OCA\Files_Sharing\Controller\ShareesAPIController::__construct(): Argument #3 ($userId) must be of type string, null given at /var/www/nextcloud/apps/files_sharing/lib/Controller/ShareesAPIController.php#106
Jun 23, 2024, 7:06:28 PM 	
Error	core	
InvalidTokenException Token does not exist: 857a68d5ccbc18ebd09857b616206824ecb03b1c5679e6d71232f3528240372b4e9c6e19ff3396711e6fde714d9801c2e9aa0bfa39ff9c2388f5dcabd37f3bdb
Renewing session token failed: Token does not exist: 857a68d5ccbc18ebd09857b616206824ecb03b1c5679e6d71232f3528240372b4e9c6e19ff3396711e6fde714d9801c2e9aa0bfa39ff9c2388f5dcabd37f3bdb
Jun 23, 2024, 7:06:23 PM 	
Error	no app in context	
BadRequest Expected filesize of 5751668 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 4358144 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jun 15, 2024, 11:58:15 AM 	
Error	no app in context	
BadRequest Expected filesize of 4430723 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 1933312 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jun 7, 2024, 3:42:03 PM 	
Error	no app in context	
BadRequest Expected filesize of 2460537 bytes but read (from Nextcloud client) and wrote (to Nextcloud storage) 8192 bytes. Could either be a network problem on the sending side or a problem writing to the storage on the server side.
Jun 6, 2024, 4:08:46 PM 

Afaik NCP supports php8.1 only at the moment. (NCP v1.54.2)
Also; Expected file size errors can be from misconfigured temp_dir in NC’s config.php and php.ini files.

Hey, thanks for your help! It’s odd that the PHP is the wrong version. Can running apt update / upgrade cause the PHP to advance too far? What should I do in this case?

I didn’t make any changes to the temp dir. What do I need to do to configure it correctly?

I will edit this comment with PHP.ini and config.php when I get home.

EDIT: It looks like my php version is back to 8.1

config.php:

...
'tempdirectory' => '/media/wb-2tb/3ncdata/data/tmp',
...

/etc/php/8.1/cli/php.ini: pastebin

/etc/php/8.1/fpm/php.ini: pastebin

What am I looking for in these configs? The path looks correct in config.php, and I am looking at https://docs.nextcloud.com/server/latest/admin_manual/installation/php_configuration.html#ini-values but nothing jumps out as responsible.

Thanks!

Yes it could, NCP users should enable unattended upgrades, as it is configured to exclude unwanted package upgrades.

Can check and follow instructions at NCP 1.50.5: PHP version 8.2 problem - how to downgrade? - #5 by Gorf

What exactly am I looking for in /etc/php/8.1/fpm/php.ini or /etc/php8.1/cli/php.ini?

It looks like the fpm version has upload_tmp_dir = /media/wb-2tb/3ncdata/data/tmp but the cli php.ini has uploadtmp_dir = /opt/ncdata/data/tmp

I will try making them both agree.

Does this make sense?