meganz/MEGAcmd

Failing consistently since 1.5.0 with Request (ADD_SYNC) finished with error: Invalid argument

haelix888 opened this issue · 8 comments

[API:info: 23:06:49] Request (ADD_SYNC) starting
[API:debug: 23:06:49] Using the hostname instead of the IP
[API:debug: 23:06:49] Using SOCKS proxy
[API:debug: 23:06:49] NOT using proxy authentication
[API:debug: 23:06:49] Informing cURL of timeout reached for 2 at 20679
[API:debug: 23:06:49] Adding curl socket 86 to 1
[API:debug: 23:06:49] Removing socket 86
[API:debug: 23:06:49] CURLMSG_DONE with HTTP status: 200 from g.api.mega.co.nz - 
[API:debug: 23:06:49] cs Received 4: [-2]
[API:warn: 23:06:49] Request (ADD_SYNC) finished with error: Invalid argument
[API:err: 23:06:49] Failed to sync folder: Invalid argument

any way I can help debug this?

polmr commented

Hi @haelix888 ,
is that a result of an attempt to set a sync?
The above log is missing the query to g.api.mega.co.nz, there we can examine if there is something wrong with the query. Note. g.api.mega.co.nz is not accepting the provided inputs: wrong arguments apparently.

Btw, that snipped of log shows that you are using a proxy. The returned response is well formed, so that is not likely to be the case. But just in case, you might want to try again without it if feasible.

Pasting a larger extract of the log. No proxy this time. I'm using 2-factor auth. All start from clean (empty cache and configuration folder). The exact same thing works with megacmd 1.4.x.

[API:info: 14:18:21] Request (LOGIN) starting
...
[API:warn: 14:18:22] Request (LOGIN) finished with error: Multi-factor authentication required
[API:debug: 14:18:22] actUponLogin login
[API:debug: 14:18:22] actUponLogin login email: xxxxx@gmail.com
[API:info: 14:18:22] Request (LOGIN) starting
[API:debug: 14:18:22] MediaInfo version: 2109
[API:debug: 14:18:22] Reinitializing the network layer
[API:debug: 14:18:22] DNS servers: 192.168.1.1
[API:debug: 14:18:22] Sending EVENT_DISCONNECT to app.
[API:debug: 14:18:22] DNS cache hit for g.api.mega.co.nz (IPv4) 66.203.125.11
[API:debug: 14:18:22] cs POST target URL: https://g.api.mega.co.nz/cs?id=xxxxxx&ak=xxxxxxx&v=2
[API:debug: 14:18:22] cs Sending 43: [{"a":"us0","user":"xxxxxxx@gmail.com"}]
[API:debug: 14:18:22] Using the IP of the hostname: 66.203.125.11
[API:debug: 14:18:22] Informing cURL of timeout reached for 2 at 4481935
[API:debug: 14:18:22] Resolving IPv4 address for g.api.mega.co.nz during connection
[API:debug: 14:18:22] Adding curl socket 75 to 2
[API:debug: 14:18:22] c-ares info received
[API:debug: 14:18:22] Received a valid IP for g.api.mega.co.nz: 66.203.125.14
[API:debug: 14:18:22] The current DNS cache record is still valid
[API:debug: 14:18:22] Request already sent using a previous DNS response
[API:debug: 14:18:22] Removing socket 75
[API:debug: 14:18:22] CURLMSG_DONE with HTTP status: 200 from g.api.mega.co.nz - 66.203.125.11
[API:debug: 14:18:22] cs Received 59: [{"s":"xxxxxxxxxxxxxxxxxxx","v":2}]
[API:warn: 14:18:22] Event 99454: Device-id not available at login
[API:debug: 14:18:22] Starting an additional Request for a batch-separately command
[API:debug: 14:18:22] DNS cache hit for g.api.mega.co.nz (IPv4) 66.203.125.11
[API:debug: 14:18:22] cs POST target URL: https://g.api.mega.co.nz/cs?id=xxxxxx&ak=xxxxxxxxx&v=2
[API:debug: 14:18:22] cs Sending 62: [{"a":"log","e":99454,"m":"Device-id not available at login"}]
[API:debug: 14:18:22] Using the IP of the hostname: 66.203.125.11
[API:debug: 14:18:22] Informing cURL of timeout reached for 2 at 4481938
[API:debug: 14:18:22] Adding curl socket 75 to 1
[API:debug: 14:18:25] Removing socket 75
[API:debug: 14:18:25] CURLMSG_DONE with HTTP status: 200 from g.api.mega.co.nz - 66.203.125.11
[API:debug: 14:18:25] cs Received 3: [0]
[API:debug: 14:18:25] DNS cache hit for g.api.mega.co.nz (IPv4) 66.203.125.11
[API:debug: 14:18:25] cs POST target URL: https://g.api.mega.co.nz/cs?id=xxxxxxxxxxx&ak=xxxxxxxxx&v=2
[API:debug: 14:18:25] cs Sending 118: [{"a":"us","user":"xxxxxx@gmail.com","uh":"xxxxxxxxxx","mfa":"165922","sek":"xxxxxx"}]
[API:debug: 14:18:25] Using the IP of the hostname: 66.203.125.11
[API:debug: 14:18:25] Informing cURL of timeout reached for 2 at 4481962
[API:debug: 14:18:25] Adding curl socket 75 to 1
[API:debug: 14:18:25] Removing socket 75
[API:debug: 14:18:25] CURLMSG_DONE with HTTP status: 200 from g.api.mega.co.nz - 66.203.125.11
[API:debug: 14:18:25] cs Received 1329: [{"csid":"xxxxxxxxxxxxxxx>
[API:debug: 14:18:25] Using an upgraded DB: /home/porc/.megaCmd/megaclient_statecache12_status_xxxxxxxxxx.db
[API:info: 14:18:25] Loading session state from local cache
[API:info: 14:18:25] Request (LOGIN) finished
[API:debug: 14:18:25] actUponLogin login
[API:debug: 14:18:25] actUponLogin login email: xxxxxx@gmail.com
[API:debug: 14:18:25] Login correct ... xxxxx@gmail.com

Then:

[debug: 14:18:31] Fetching nodes ||####################################################################################################################################################################|(22/>
...
[API:debug: 14:18:33] Nodes updated: 84258
[debug: 14:18:33] 2098 folders added or updated 
[debug: 14:18:33] 81075 files added or updated 
...
[API:info: 14:18:33] Request (ACCOUNT_DETAILS) starting
[API:info: 14:18:34] Request (ACCOUNT_DETAILS) finished
[API:info: 14:18:34] Request (GET_PSA) starting
[API:warn: 14:18:34] Request (GET_PSA) finished with error: Not found                  -> this happens in previous version also and I think is benign
[API:info: 14:18:34] Request (ACCOUNT_DETAILS) starting
[API:info: 14:18:34] Request (ACCOUNT_DETAILS) finished
...
[API:debug: 14:18:34] Excluded name: Logs
[API:debug: 14:18:34] Excluded name: Snapshots
[API:info: 14:18:34] Request (ADD_SYNC) starting
[API:debug: 14:18:34] Adding sync: /mnt/data vs /data
[API:debug: 14:18:34] DNS cache hit for g.api.mega.co.nz (IPv4) 66.203.125.11
[API:debug: 14:18:34] cs POST target URL: https://g.api.mega.co.nz/cs?id=apunoxibgd&sid=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&ak=BdARkQSQ&v=2
[API:debug: 14:18:34] cs Sending 176: [{"a":"sp","t":0,"h":"iIAEESoK","l":"xxxxxxxx","s":1,"ss":0,"e":"xxxxxxxxxx>
[API:debug: 14:18:34] Using the IP of the hostname: 66.203.125.11
[API:debug: 14:18:34] Informing cURL of timeout reached for 2 at 4482059
[API:debug: 14:18:34] Adding curl socket 85 to 1
[API:debug: 14:18:34] Removing socket 85
[API:debug: 14:18:34] CURLMSG_DONE with HTTP status: 200 from g.api.mega.co.nz - 66.203.125.11
[API:debug: 14:18:34] cs Received 4: [-2]
[API:warn: 14:18:34] Request (ADD_SYNC) finished with error: Invalid argument
[API:err: 14:18:34] Failed to sync folder: Invalid argument
[API:debug: 14:18:46] Informing cURL of timeout reached for 2 at 4482177
[API:debug: 14:19:03] Removing socket 75

I believe everything looks good until the ADD_SYNC request.

@polmr thanks and lemme know how to help.

polmr commented

Hi @haelix888 , thanks for posting that out.
What is your operating system?
There is some issue when trying to gather an identifier for your computer.
Ideally, there should be some /etc/machine-id or /var/lib/dbus/machine-id file in your computer (assuming linux), but it does not seem to be the case for you.
A nasty way to circumvent this would be to ensure one of those files contains something useful:

sudo echo "somerandomidentifiergoeshere1234" > /etc/machine-id

Please, let us know any particularities on your operating system, so that we can try to find a general fix, just in case, other users are affected

That was it, thanks.

I was running megacmd inside a recent linux Docker container where /etc/machine-id was missing.

A more correct way to generate that file is:

dbus-uuidgen > /etc/machine-id

After which the file contents is something like

$ cat /etc/machine-id 
ab4fcf0cdcefa7ad2dbb32186229d14a

A normal Linux machine (at least those with a desktop environment) will have that file, so I'm not sure if you need to do anything. Much appreciate the hint.

polmr commented

Thanks for reporting back @haelix888 !

I'm using MEGAcmd in termux and I don't have permission to write /etc/machine-id, what could be an alternative to setting the ID of the machine...?