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

Error "missing field mod at line 1 column 99" when initiating sync from client #56

Closed
ndwarshuis opened this issue Nov 28, 2020 · 7 comments

Comments

@ndwarshuis
Copy link

Observed behavior

After initiating sync in the Anki client, I see the following:

A network error occurred.
Error details: ⁨error decoding response body: missing field `mod` at line 1 column 99⁩

It also tells me my ID and password are incorrect.

In the server I see the following after making the request:

...startup messages...
anki-sync-server    | [2020-11-28 19:20:05,431]:INFO:ankisyncd.http:172.30.0.1 "GET /msync/begin?k=c63b69986acdcaff9ad11f877163d90c&v=anki%2C2.1.35+%2884dcaa86%29%2Clin%3Aarch%3Arolling HTTP/1.0" 403 157
anki-sync-server    | [2020-11-28 19:20:05,477]:INFO:ankisyncd.CollectionThread[ndwar]:Starting...
anki-sync-server    | [2020-11-28 19:20:05,478]:INFO:ankisyncd.CollectionThread[ndwar]:Running meta(*[], **{'v': 10, 'cv': 'anki,2.1.35 (84dcaa86),lin:arch:rolling'})
anki-sync-server    | [2020-11-28 19:20:05,488]:INFO:ankisyncd.http:172.30.0.1 "POST /sync/meta HTTP/1.0" 200 99

Server information

Anki sync server was set up using docker-compose:

version: "3"

services:
  anki-sync-server:
    image: kuklinistvan/anki-sync-server:latest
    container_name: anki-sync-server

    restart: always
    ports:
    - "9005:27701"
    volumes:
    - /mnt/data/docker-vols/anki-sync-server:/app/data

And I have it reverse-proxied using nginx (minimal config):

#user html;
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include mime.types;
    default_type application/octet-stream;
    types_hash_max_size 4096;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log main;
    error_log /var/log/nginx/error.log notice;
    
    sendfile on;
    keepalive_timeout 65;
    gzip  on;

    server {
	listen 80;
        return 404;
    }

    server {
        listen 80;
        server_name ankiurl;
	location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header HOST $host;
            proxy_set_header Referer $http_referer;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Host $host:$server_port;
            include conf.d/proxy-headers.conf;
            include conf.d/proxy-x-headers.conf;
	    proxy_http_version 1.0;
            proxy_pass http://127.0.0.1:9005;
	}
    }
}

User was created without error:

/app/anki-sync-server # ./ankisyncctl.py adduser myuser
Enter password for myuser 

Client information

Debug output from Help > About

    
    Anki 2.1.35 (84dcaa86) Python 3.8.6 Qt 5.15.2 PyQt 5.15.2
    Platform: Linux
    Flags: frz=False ao=True sv=1
    Add-ons, last update check: 2020-11-28 10:23:13
    
    
    ===Add-ons (active)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    '' ['ankisyncd', 0, 'None', '']
    
    ===IDs of active AnkiWeb add-ons===
    
    
    ===Add-ons (inactive)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    

Contents of the ankisyncd addon:

import os

addr = "http://myurl/"
os.environ["SYNC_ENDPOINT"] = addr + "sync/"
os.environ["SYNC_ENDPOINT_MEDIA"] = addr + "msync/"
@hblr
Copy link

hblr commented Dec 2, 2020

I am having the same issue and unfortunately no solution yet. However, I can provide some thoughts on it. Have you tried to sync with another application (e.g. AnkiDroid)?
For me the sync works with AnkiDroid. Hence the issue seems to be related to the Anki application itself.
Assuming the sync functionality works with the official AnkiWeb (I have not tested it yet), I suspect an API incompatibility between this anki-sync-server and the anki desktop application (version 2.1.35).

@ndwarshuis
Copy link
Author

@hblr I just tried AnkiDroid and it appears to sync (albeit nothing since the server has nothing on it). But no 40X HTTP errors.

Server output when I sync with AnkiDroid:

anki-sync-server    | [2020-12-04 20:49:18,635]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16
anki-sync-server    | [2020-12-04 20:49:19,721]:INFO:ankisyncd.CollectionThread[ndwar]:Running meta(*[], **{'v': 9, 'cv': 'ankidroid,2.14.2,android:8.1.0:Pixel XL'})
anki-sync-server    | [2020-12-04 20:49:19,756]:INFO:ankisyncd.http:172.30.0.1 "POST /sync/meta HTTP/1.0" 200 108
anki-sync-server    | [2020-12-04 20:49:19,809]:INFO:ankisyncd.CollectionThread[ndwar]:Running begin(*[], **{'skey': '68ff8e1a'})
anki-sync-server    | [2020-12-04 20:49:19,811]:INFO:ankisyncd.http:172.30.0.1 "POST /msync/begin HTTP/1.0" 200 49
anki-sync-server    | [2020-12-04 20:49:24,022]:INFO:ankisyncd.http:127.0.0.1 "GET / HTTP/1.1" 200 16

I'm guessing the number for the 'v' key in "Running meta..." above (and in the OP) is the protocol version? It's 9 for AnkiDroid, and 10 for the desktop client. I'm not sure what that means yet (or if I'm right).

@hblr
Copy link

hblr commented Dec 7, 2020

I'm guessing the number for the 'v' key in "Running meta..." above (and in the OP) is the protocol version? It's 9 for AnkiDroid, and 10 for the desktop client. I'm not sure what that means yet (or if I'm right).

By looking into the source code, parameter v seems to be the sync protocol version and cv a more detailed client information string.
https://github.com/ankicommunity/anki-sync-server/blob/f8a1fb0f9c2c66e59ae260734697d32603e2b58a/src/ankisyncd/sync_app.py#L86-L92

@levindu
Copy link

levindu commented Dec 17, 2020

@ndwarshuis
That docker image has a rather old server code.
You'll have to build a new one yourself. See this PR .
I've archived a successful sync with Anki 2.1.35 in Arch Linux.

@valuex
Copy link
Contributor

valuex commented Mar 20, 2021

Anki Desktop: 2.1.42

I've tried to use @levindu 's docker image. And It is OK for uploading, but fails to downloading.
When it comes to downloading, the error message says that the user name or password is incorrect.
Any comment on this will be appreciated. Thanks.

@ndwarshuis
Copy link
Author

I finally got back to this and got it to work with Anki 2.1.35 (same build as in the OP). I tried uploading my local deck and nuking my local deck and redownloading it. All is well (no password issues or errors).

@levindu was indeed correct in that it was old server code that was causing this bug. Simply updating the server fixed the bug I was originally having (and so far has not introduced any new bugs).

Just to be clear for anyone else who stumbles upon this, I used anki-sync-server at commit 43f4934. This was somewhat arbitrary but I simply went forward in time from @levindu 's PR until it worked.

I also used the docker-compose files from here (note the commit hash), and the only change I made was I added the following lines after git clone in bin/download-release.sh to pull the server commit I wanted:

cd anki-sync-server
git reset --hard 43f4934de8add5f23aa9318a84c756f27214fb72
cd ..

Obviously this could be simpler if I just pulled a version tag, but the latest version is from Dec 2020 and it didn't build correctly.

@Zocker1999NET
Copy link

Zocker1999NET commented Jul 14, 2022

For people like me finding this issue later: The Docker image URI has changed (that change is not reflected in the README of https://github.com/ankicommunity/anki-devops-services at time of writing). It is now available at https://hub.docker.com/r/ankicommunity/anki-sync-server (e.g. ankicommunity/anki-sync-server:20220516), see ankicommunity/anki-devops-services#47

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

No branches or pull requests

5 participants