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]: server replied: Precondition Failed on nextcloudclientcmd on Ubuntu #7935

Closed
4 of 8 tasks
lucas9933 opened this issue Feb 26, 2025 · 23 comments
Closed
4 of 8 tasks
Labels

Comments

@lucas9933
Copy link

lucas9933 commented Feb 26, 2025

⚠️ Before submitting, please verify the following: ⚠️

Bug description

My nextcloudcmd client is failing with the error: Sync error: "Server replied with an error while reading directory "" : Error transferring https://localhost/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/ - server replied: Precondition Failed"

I just updated to server version 31 and the client is 3.15.3.
Client:
Nextcloud version 3.15.3-20250107.145041.a595d5bcb-1.0~noble1
Using Qt 6.4.2, built against Qt 6.4.2
Using 'OpenSSL 3.0.13 30 Jan 2024'
Running on Ubuntu 24.04.2 LTS, x86_64

02-26 17:11:00:221 [ info nextcloud.sync.database ]:	sqlite3 version "3.45.1"
02-26 17:11:00:221 [ info nextcloud.sync.database ]:	sqlite3 locking_mode= "exclusive"
02-26 17:11:00:221 [ info nextcloud.sync.database ]:	sqlite3 journal_mode= "wal"
02-26 17:11:00:221 [ info nextcloud.sync.database ]:	sqlite3 synchronous= "NORMAL"
02-26 17:11:00:222 [ info nextcloud.sync.engine ]:	There are 51612999680 bytes available at "/home/lucas/Documents/Dokumente/Projekte/Server/"
02-26 17:11:00:222 [ info nextcloud.sync.engine ]:	Sync with existing sync journal
02-26 17:11:00:222 [ info nextcloud.sync.engine ]:	"Using Qt 6.4.2 SSL library OpenSSL 3.0.13 30 Jan 2024 on Ubuntu 24.04.2 LTS"
02-26 17:11:00:222 [ info nextcloud.sync.engine ]:	NOT Using Selective Sync
02-26 17:11:00:222 [ info nextcloud.sync.engine ]:	#### Discovery start ####################################################
02-26 17:11:00:222 [ info nextcloud.sync.engine ]:	Server "31.0.0.18" 
02-26 17:11:00:222 [ info nextcloud.sync.discovery ]:	STARTING "" OCC::ProcessDirectoryJob::NormalQuery "" OCC::ProcessDirectoryJob::NormalQuery
02-26 17:11:00:222 [ info nextcloud.sync.accessmanager ]:	6 "PROPFIND" "https://localhost/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/" has X-Request-ID "b940ee18-4aef-4f26-a3a4-766b74554175"
02-26 17:11:00:222 [ info nextcloud.sync.networkjob ]:	OCC::LsColJob created for "https://localhost" + "Dokumente/Dokumente/Projekte/Server/" ""
02-26 17:11:00:235 [ warning nextcloud.sync.networkjob ]:	QNetworkReply::UnknownContentError "Server replied \"412 Precondition Failed\" to \"PROPFIND https://localhost/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/\"" QVariant(int, 412)
02-26 17:11:00:235 [ info nextcloud.sync.networkjob.lscol ]:	LSCOL of QUrl("https://localhost/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/") FINISHED WITH STATUS "UnknownContentError Server replied \"412 Precondition Failed\" to \"PROPFIND https://localhost/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/\""
02-26 17:11:00:235 [ warning nextcloud.sync.discovery ]:	LSCOL job error "Error transferring https://localhost/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/ - server replied: Precondition Failed" 412 QNetworkReply::UnknownContentError
02-26 17:11:00:235 [ warning nextcloud.sync.discovery ]:	Server error in directory "" 412
02-26 17:11:00:235 [ warning default ]:	Sync error: "Server replied with an error while reading directory \"\" : Error transferring https://localhost/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/ - server replied: Precondition Failed"
02-26 17:11:00:235 [ info nextcloud.sync.engine ]:	Sync run took  13 ms
02-26 17:11:00:258 [ info nextcloud.sync.database ]:	Closing DB "/home/lucas/Documents/Dokumente/Projekte/Server/.sync_564cbb13e724.db"

Steps to reproduce

Execute
nextcloudcmd --user <user> --password <password> --path <remotepath> <localpath> https://localhost

Expected behavior

Normal file sync via the commandline client

Which files are affected by this bug

All Files

Operating system

Linux

Which version of the operating system you are running.

Ubuntu 24.04.2 LTS

Package

Official Linux AppImage

Nextcloud Server version

31.0.0.18

Nextcloud Desktop Client version

3.15.3-20250107.145041.a595d5bcb-1.0~noble1

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

Updated to a major version (ex. 3.3.6 to 3.4.0)

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

Are you using an external user-backend?

  • Default internal user-backend
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Nextcloud Server logs

{"reqId":"022uBPNbXPaQBqwcfaGt","level":2,"time":"2025-02-26T16:23:06+00:00","remoteAddr":"127.0.0.1","user":"lucas","app":"no app in context","method":"PROPFIND","url":"/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/","message":"Request does not pass strict cookie check","userAgent":"Mozilla/5.0 (Linux) mirall/3.15.3-20250107.145041.a595d5bcb-1.0~noble1 (Nextcloud, ubuntu-6.11.0-17-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"31.0.0.18","data":[]}
{"reqId":"yoYOQE22DvG3IO5LMamH","level":2,"time":"2025-02-26T16:23:36+00:00","remoteAddr":"127.0.0.1","user":"lucas","app":"no app in context","method":"PROPFIND","url":"/remote.php/dav/files/lucas/Dokumente/Dokumente/Projekte/Server/","message":"Request does not pass strict cookie check","userAgent":"Mozilla/5.0 (Linux) mirall/3.15.3-20250107.145041.a595d5bcb-1.0~noble1 (Nextcloud, ubuntu-6.11.0-17-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"31.0.0.18","data":[]}

Additional info

No response

@Aohzan
Copy link

Aohzan commented Feb 27, 2025

Same issue with nextcloudcmd:

Feb 27 12:03:46 server nextcloudcmd[219118]: 02-27 12:03:46:937 [ warning nextcloud.sync.networkjob ]:        QNetworkReply::UnknownContentError "Server replied \"412 Precondition Failed\" to \"PROPFIND https://xxxx/remote.php/dav/files/ME/\"" QVariant(int, 412)
Feb 27 12:03:46 server nextcloudcmd[219118]: 02-27 12:03:46:937 [ info nextcloud.sync.networkjob.lscol ]:        LSCOL of QUrl("https://xxxx/remote.php/dav/files/ME/") FINISHED WITH STATUS "UnknownContentError Server replied \"412 Precondition Failed\" to \"PROPFIND https://xxxx/remote.php/dav/files/ME/\""
Feb 27 12:03:46 server nextcloudcmd[219118]: 02-27 12:03:46:937 [ warning nextcloud.sync.discovery ]:        LSCOL job error "Error transferring https://xxxx/remote.php/dav/files/ME/ - server replied: Precondition Failed" 412 QNetworkReply::UnknownContentError
Feb 27 12:03:46 server nextcloudcmd[219118]: 02-27 12:03:46:937 [ warning nextcloud.sync.discovery ]:        Server error in directory "" 412
Feb 27 12:03:46 server nextcloudcmd[219118]: 02-27 12:03:46:937 [ warning default ]:        Sync error: "Server replied with an error while reading directory \"\" : Error transferring https://xxx/remote.php/dav/files/ME/ - server replied: Precondition Failed"

server's side errors

RuntimeException The loading of lazy AppConfig values have been triggered by app "bruteForce"
InvalidTokenException Token does not exist: token does not exist
Token is not valid: Token does not exist: token does not exist 

I recreated the app token but same error, I have nothing in the bruteforce attempt list

@camilasan
Copy link
Member

I just updated to server version 31 and the client is 3.15.3.

At first glance this is not looking like a desktop client issue.

Can you upload files in the browser?
Do you get the same running nextcloud, not nextcloudcmd?

@mruediger
Copy link

mruediger commented Feb 27, 2025

Same issue here. I am also getting the Request does not pass strict cookie check error. I wonder if anyone knows the user-agent nextcloudcmd is passing so I can try to tweak: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#csrf-optout

EDIT @camilasan yes I can upload files through the browser and the Android APP.

@camilasan
Copy link
Member

Same issue here. I am also getting the Request does not pass strict cookie check error. I wonder if anyone knows the user-agent nextcloudcmd is passing so I can try to tweak: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#csrf-optout

the same as nextcloud: https://github.com/nextcloud/desktop/blob/master/src/common/utility.cpp#L167-L178

let us know if that solved your issue.

@camilasan
Copy link
Member

With master and fresh server 31.0.0.18, I couldn't reproduce this error.

Could you try it 3.16.0-rc3?
https://github.com/nextcloud-releases/desktop/releases/tag/v3.16.0-rc3

@lucas9933
Copy link
Author

I just updated to server version 31 and the client is 3.15.3.

At first glance this is not looking like a desktop client issue.

Can you upload files in the browser? Do you get the same running nextcloud, not nextcloudcmd?

Hi, this is only a nextcloudcmd issue for me. The GUI and browser clients work fine.

@nilsding
Copy link
Member

@Aohzan @mruediger could you also post which exact version of the client you're using? how did you install it? which distro/OS are you running?

I cannot reproduce this with 3.15.3 from the openSUSE repos (which uses the same commit as the OP's build) against a 31.0.0.18 server either. My nextcloudcmd -v:

Nextcloud version 3.15.3daily
Git revision a595d5bcb6f13f4ea4080b694682a5ae43e2f769
Using Qt 6.8.2, built against Qt 6.8.1
Using 'OpenSSL 3.2.3 3 Sep 2024'
Running on openSUSE Tumbleweed, x86_64

@Aohzan
Copy link

Aohzan commented Feb 27, 2025

nextcloudcmd -v
Nextcloud version 3.7.3git
Using Qt 5.15.8, built against Qt 5.15.8
Using 'OpenSSL 3.0.15 3 Sep 2024'
Running on Debian GNU/Linux 12 (bookworm), x86_64

I use the last version on Debian repo

nextcloud-desktop-cmd:
  Installed: 3.7.3-1+deb12u1
  Candidate: 3.7.3-1+deb12u1
  Version table:
 *** 3.7.3-1+deb12u1 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status

@camilasan
Copy link
Member

Nextcloud version 3.7.3git

Could you upgrade? That could explain the issue.

@Aohzan
Copy link

Aohzan commented Feb 27, 2025

ok but as there is no new version available on Debian repo, do I need to build it on my own or there is some .deb or binaries somewhere ?

@lucas9933
Copy link
Author

@Aohzan @mruediger could you also post which exact version of the client you're using? how did you install it? which distro/OS are you running?

I cannot reproduce this with 3.15.3 from the openSUSE repos (which uses the same commit as the OP's build) against a 31.0.0.18 server either. My nextcloudcmd -v:

Nextcloud version 3.15.3daily
Git revision a595d5bcb6f13f4ea4080b694682a5ae43e2f769
Using Qt 6.8.2, built against Qt 6.8.1
Using 'OpenSSL 3.2.3 3 Sep 2024'
Running on openSUSE Tumbleweed, x86_64

I tried the apt and snap packages, but get the same results with both of them. I am currently trying to compile it to get the newest version, as I could not find any packages for the 3.16 version

Just as a sidenote, on my Ubuntu 22 Laptop it works fine:
Nextcloud version 3.15.3-20250107.145041.a595d5bcb-1.0~noble1
Using Qt 6.4.2, built against Qt 6.4.2
Using 'OpenSSL 3.0.13 30 Jan 2024'
Running on Ubuntu 24.04.2 LTS, x86_64

@camilasan
Copy link
Member

@Aohzan
Copy link

Aohzan commented Feb 27, 2025

Its dependencies are not available on Debian 12, so it's not so easy

@mruediger
Copy link

mruediger commented Feb 27, 2025

I am running NixOS. I tried the stable and unstable channel. I also bumped the version to 3.16.0-rc3 on my machine.

02-27 16:03:21:166 [ info nextcloud.sync.accessmanager ]:	6 "PROPFIND" "https://xxx.xxx.xxx/remote.php/dav/files/mruediger/doc/" has X-Request-ID "6a092336-c6e3-45a7-a1ff-4d6c139a8840"
02-27 16:03:21:166 [ info nextcloud.sync.networkjob ]:	OCC::LsColJob created for "https://xxx.xxx.xxx" + "doc/" ""
02-27 16:03:21:234 [ warning nextcloud.sync.networkjob ]:	QNetworkReply::UnknownContentError "Server replied \"412 Precondition Failed\" to \"PROPFIND https://xxx.xxx.xxx/remote.php/dav/files/mruediger/doc/\"" QVariant(int, 412)
02-27 16:03:21:234 [ info nextcloud.sync.networkjob.lscol ]:	LSCOL of QUrl("https://xxx.xxx.xxx/remote.php/dav/files/mruediger/doc/") FINISHED WITH STATUS "UnknownContentError Server replied \"412 Precondition Failed\" to \"PROPFIND https://xxx.xxx.xxx/remote.php/dav/files/mruediger/doc/\""
02-27 16:03:21:234 [ warning nextcloud.sync.discovery ]:	LSCOL job error "Error transferring https://xxx.xxx.xxx/remote.php/dav/files/mruediger/doc/ - server replied: Precondition Failed" 412 QNetworkReply::UnknownContentError
02-27 16:03:21:234 [ warning nextcloud.sync.discovery ]:	Server error in directory "" 412
02-27 16:03:21:234 [ warning default ]:	Sync error: "Server replied with an error while reading directory \"\" : Error transferring https://xxx.xxx.xxx/remote.php/dav/files/mruediger/doc/ - server replied: Precondition Failed"

❯ nextcloudcmd --version
Nextcloud version 3.15.83
Git revision 98b2996a19910a4b3e033c8d27e4ed6662dc72c8
Using Qt 6.8.1, built against Qt 6.8.1
Using 'OpenSSL 3.3.2 3 Sep 2024'
Running on NixOS 24.11 (Vicuna), x86_64

and on my server (using nextcloud:fpm-alpine):

docker exec -it -u 1010 nc_cron ./occ status
  - installed: true
  - version: 31.0.0.18
  - versionstring: 31.0.0
  - edition:
  - maintenance: false
  - needsDbUpgrade: false
  - productname: Nextcloud
  - extendedSupport: false

@waliwdenko
Copy link

@camilasan sid is unstable branch of debian, we cannot install it on production systems

i have the same problem with nextcloudcmd 3.15.2 in alpine container

@waliwdenko
Copy link

i built 3.16.0-rc3 and the problem still exists

anyone know how to fix it?

Nextcloud version 3.15.83
Git revision 98b2996
Using Qt 6.8.0, built against Qt 6.8.0
Using 'OpenSSL 3.3.3 11 Feb 2025'
Running on Alpine Linux v3.21, x86_64

@camilasan
Copy link
Member

i built 3.16.0-rc3 and the problem still exists

anyone know how to fix it?

Could you check the server logs and configuration?
That could be the issue.

@lucas9933
Copy link
Author

Same issue here. I am also getting the Request does not pass strict cookie check error. I wonder if anyone knows the user-agent nextcloudcmd is passing so I can try to tweak: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#csrf-optout

EDIT @camilasan yes I can upload files through the browser and the Android APP.

The user agent is in the error message, putting it into the nextcloud config seems to solve the issue for me

@camilasan
Copy link
Member

I am closing the ticket now given that we couldn't reproduce it and that it seems to be a configuration issue.

@manliojrc
Copy link

manliojrc commented Mar 3, 2025

Same issue here. I am also getting the Request does not pass strict cookie check error. I wonder if anyone knows the user-agent nextcloudcmd is passing so I can try to tweak: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#csrf-optout
EDIT @camilasan yes I can upload files through the browser and the Android APP.

The user agent is in the error message, putting it into the nextcloud config seems to solve the issue for me

same issue here, nextcloud 31.0.0.18 and nextcloudcmd 3.15.3-20250107.145041.a595d5bcb-1.0~jammy1

how do you put the user agent in the config file?
from server logs, mine seems to be "Mozilla/5.0 (Linux) mirall/3.15.3-20250107.145041.a595d5bcb-1.0~jammy1 (Nextcloud, ubuntu-6.8.0-51-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)"

@philvx
Copy link

philvx commented Mar 4, 2025

I added

  'csrf.optout' => [
        '/^.*nextcloudcmd.*/',
  ],

to config/config.php and now it seems to work again. But your user agent differs. Instead you could try

  'csrf.optout' => [
        '/^.*Nextcloud.*/',
  ],

@ufgkirk
Copy link

ufgkirk commented Mar 9, 2025

I am also experiencing this issue, and the suggested fix above by adding csrf.optout to my config.php so far does not seem to be working around the issue.

My client device is Debian 12, using the CLI client.
nextcloud-desktop-cmd 3.7.3-1+deb12u1

03-08 20:58:20:026 [ info nextcloud.sync.engine ]: Server "31.0.0.18"
03-08 20:58:20:027 [ info nextcloud.sync.discovery ]: STARTING "" OCC::ProcessDirectoryJob::NormalQuery "" OCC::ProcessDirectoryJob::NormalQuery
03-08 20:58:20:027 [ info nextcloud.sync.accessmanager ]: 6 "PROPFIND" "https://my-nextcloud-url.com/remote.php/dav/files/Concord/" has X-Request-ID "2ce23074-xxxx-redacted-xxxx-8870342725d7"
03-08 20:58:20:027 [ info nextcloud.sync.networkjob ]: OCC::LsColJob created for "https://my-nextcloud-url.com" + "/" "OCC::DiscoverySingleDirectoryJob"
03-08 20:58:20:027 [ info nextcloud.sync.engine ]: shouldDiscoverLocaly "" true
03-08 20:58:20:099 [ warning nextcloud.sync.networkjob ]: QNetworkReply::UnknownContentError "Server replied "412 Precondition Failed" to "PROPFIND https://my-nextcloud-url.com/remote.php/dav/files/Concord/\"" QVariant(int, 412)
03-08 20:58:20:099 [ info nextcloud.sync.networkjob.lscol ]: LSCOL of QUrl("https://my-nextcloud-url.com/remote.php/dav/files/Concord/") FINISHED WITH STATUS "UnknownContentError Server replied "412 Precondition Failed" to "PROPFIND https://my-nextcloud-url.com/remote.php/dav/files/Concord/\""
03-08 20:58:20:099 [ warning nextcloud.sync.discovery ]: LSCOL job error "Error transferring https://my-nextcloud-url.com/remote.php/dav/files/Concord/ - server replied: Precondition Failed" 412 QNetworkReply::UnknownContentError
03-08 20:58:20:099 [ warning nextcloud.sync.discovery ]: Server error in directory "" 412
03-08 20:58:20:099 [ warning default ]: Sync error: "Server replied with an error while reading directory "" : Error transferring https://my-nextcloud-url.com/remote.php/dav/files/Concord/ - server replied: Precondition Failed"
03-08 20:58:20:099 [ info nextcloud.sync.engine ]: Sync run took 73 ms

@mbentley
Copy link

mbentley commented Mar 9, 2025

@ufgkirk - I just tested with the nextcloud-desktop-cmd 3.7.3-1+deb12u1 client in a container with the suggested config and it works as expected. Maybe confirm that your config syntax is correct? Here's the end of my config where you can see I've appended :

...
  'defaultapp' => 'files',
  'files.chunked_upload.max_size' => 26214400,
  'csrf.optout' =>
  array (
    0 => '/^.*nextcloudcmd.*/',
    1 => '/^.*Nextcloud.*/',
  ),
);

If you're using the short array syntax (where you'd see $CONFIG = [ at the top of your config instead of CONFIG = array (, it looks like the config.sample.php would suggest a syntax like this:

'csrf.optout' => [
    '/^.*nextcloudcmd.*/',
    '/^.*Nextcloud.*/',
],

I don't know if the two formats are incompatible - I haven't looked but maybe that's it.

Otherwise, it might be a good idea to check your web server logs to see what is being reported as the user agent. For example, I can see in my nginx logs what the UserAgent is:

192.168.0.1 - user [09/Mar/2025:11:32:53 +0000] "https://nextcloud.example.com" "GET /status.php HTTP/1.1" 200 152 "-" "Mozilla/5.0 (Linux) mirall/3.7.3git (nextcloudcmd, debian-6.1.0-31-amd64 ClientArchitecture: x86_64 OsArchitecture: x86_64)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants