Sync from PC to phone broken in Contact Syncml Replace

REPRODUCIBILITY (% or how often): 100%
BUILD ID = OS VERSION (Settings > About product): 3.3.0.16
HARDWARE (XA2, Xperia 10…): Xperia X
UI LANGUAGE: English
REGRESSION: (compared to previous public release: Yes, No, ?): Yes

DESCRIPTION: When contact is modified on the PC and synced to the phone it throws error

PRECONDITIONS:

STEPS TO REPRODUCE:

  1. change contact details on the PC
  2. run the sync via syncml (syncevolution/PC and buteo-syncml/SFOS)

EXPECTED RESULT:

sync succeeds as in the past 10y

ACTUAL RESULT:

sync fails (see below)

ADDITIONAL INFORMATION:

Some more details here PoC Bluez5 Buteo Syncml Plugins and here
https://together.jolla.com/question/215981/can-not-delete-contact-details/
It seems it started or was noticed in 2019.
I wonder if it has to do with the update of wbxml around that time (buteo-syncml 0.5.12).

From the msyncd log

Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Processing item for replace: 4 / 0
Mar 17 01:08:34 Sailfish invoker[31228]: obex_data_indication(): Got 623 bytes msg len=626
Mar 17 01:08:34 Sailfish invoker[31228]: obex_data_request(): len = 3 bytes
Mar 17 01:08:34 Sailfish invoker[31228]: do_write(): sending 3 bytes
Mar 17 01:08:34 Sailfish syncml-server[31263]: [W] unknown:0 - Variant value is a QStringList but the property’s value type is neither CompoundType or ListType
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Item queued for replace
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Committing 0 added items
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Checking item 4 / 0 for conflict
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - No conflict detected
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Committing 1 replaced items
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Items to Modify : 1
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - converted 1 concatenated vCards into 1 versit documents
Mar 17 01:08:34 Sailfish syncml-server[31263]: [W] unknown:0 - Failed to extract avatar data from vCard PHOTO property
Mar 17 01:08:34 Sailfish syncml-server[31263]: [W] unknown:0 - “Opened contacts database: /home/nemo/.local/share/system/privileged/Contacts/qtcontacts-sqlite/contacts.db Locale: en_GB”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [W] unknown:0 - “Cannot buildWhere with unknown filter type: 0”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [W] unknown:0 - “Failed to create WHERE expression: invalid filter specification”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - imported 1 contacts from 1 versit documents
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Id of the contact to be replaced “qtcontacts:org.nemomobile.contacts.sqlite::sql-655”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Replacing item’s ID QContact(QContactId(“sql-655”))
QContactDetail(detailType=26, key=16, 0=QVariant(int, 0))
QContactDetail(detailType=25, key=17, 0=QVariant(QDateTime, QDateTime(2021-03-17 01:08:17.000 UTC Qt::TimeSpec(UTC))))
QContactDetail(detailType=15, key=18, 3=QVariant(QString, “Иванчевски”))
QContactDetail(detailType=5, key=20, 0=QVariant(QString, “User”))
QContactDetail(detailType=19, key=25, 2=QVariant(QStringList, ("", “”, “”)), 5=QVariant(QString, “”))
QContactDetail(detailType=20, key=27, 0=QVariant(QString, “+35xxxxxxxx”), 1=QVariant(QList, ))
QContactDetail(detailType=20, key=28, 0=QVariant(QString, “+112345”), 5000=QVariant(QList, ))
QContactDetail(detailType=1, key=29)
Mar 17 01:08:34 Sailfish syncml-server[31263]: [W] unknown:0 - “Error updating contact sql-655: 1”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Batch Modification of Contacts Failed
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - contact with id QContactId(“sql-655”) and index 0 is in error
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Id set in Storage “qtcontacts:org.nemomobile.contacts.sqlite::sql-655”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Item 4 / 0 committed
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Commit result: COMMIT_GENERAL_ERROR
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Committing 0 deleted items
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Sync state changed to 206
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Received message processed
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Sending next message…
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - MaxMsg size 150000
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - useWbxml false
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - MessageSize: 832
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Message generated with following parameters:
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Maximum size reported by remote device: 150000
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Estimated overhead: 15000
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Message size threshold value was: 135000
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Remaining bytes was: 134178
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Next message sent
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Waiting for OBEX GET
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - SyncAgent: Synchronization status changed to: 205
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - OBEX Event: 1 Mode: 1 Cmd: 3 Resp: 0
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - SyncML new state 205
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - OBEX Event: 2 Mode: 1 Cmd: 3 Resp: 0
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - SyncAgent: Item processed
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Found connection id: 1
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Modification type: 3
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Found type: “application/vnd.syncml+wbxml”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - ModificationType database: 0
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Encoding to wbXML
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Local database: “./contacts”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Encoding successful
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Database type: “text/x-vcard”
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - wbXML buffer size: 253
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - Committed items: 1
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - WbXML encoding successful
Mar 17 01:08:34 Sailfish syncml-server[31263]: [D] unknown:0 - SyncAgent: Synchronization status changed to: 206

It looks like the sqlite contact.db is messed up. I have 1164 records in the DB, but actually only 268 contacts.
How can I clean up this mess?