kcd icon indicating copy to clipboard operation
kcd copied to clipboard

Contacts sync kills the link: unmarshal error on phone's response disconnects device (1.18.1)

Open ekollof opened this issue 2 months ago • 3 comments

Summary

Since 1.18.x, every established link to my phone dies in under a second. Debug logs show the daemon's OnConnect contacts sync (kdeconnect.contacts.request_all_uids_timestamps) goes out, and ~365ms later the reader hits protocol: unmarshal: invalid character 'f' after top-level value and drops the connection. A manual kcd contacts sync while connected triggers the same disconnect. The phone never produces any contacts.updated event and the contacts cache stays empty.

Versions

  • kcd 1.18.1 (AUR kcd-bin 1.18.1-1; kcd --version: commit 10485ed3d81edcef4cb6f155ef65ca1418f92766, built 2026-09-16)
  • Phone: Pixel 10a, protocol_version 8, paired (KDE Connect Android app version unknown — can supply)
  • Desktop: Arch Linux, systemd user unit

Side note: kcd status --json reports version: dev even on this release build, so consumers cannot version-gate on 1.18.

Repro

  1. Pair phone, ensure link is up.
  2. kcd contacts sync <device-id> (or just wait for the OnConnect auto-sync).
  3. Device disconnects within a second.

Evidence (daemon at debug level)

18:07:11.650 sending packet device_id=37257a9324b3443590b2596818699806 type=kdeconnect.contacts.request_all_uids_timestamps
18:07:11.650 sending packet ... type=kdeconnect.systemvolume.request
18:07:11.666 sending packet ... type=kdeconnect.systemvolume
18:07:11.770 sending packet ... type=kdeconnect.runcommand
18:07:12.015 read packet error (disconnecting) ... error="protocol: unmarshal: invalid character 'f' after top-level value"
18:07:12.015 device disconnected ...

Full pattern in the journal: 10 consecutive connects each followed by a disconnect 200–400ms later. Sessions on the pre-contacts daemon (same phone, same network) held for 17+ minutes with stable battery/MPRIS/SMS traffic, so the contacts exchange is the trigger. Other OnConnect packets (battery, connectivity, systemvolume, runcommand, mpris player-list) are pre-existing types that worked fine all day.

Expected

  • A malformed/unexpected packet from the phone should not kill the whole link; at worst the contacts sync should fail with an error and emit nothing.
  • kcd contacts sync should surface the failure instead of hanging up on the device.

Workaround

contacts = false under [plugins] in kcd.toml + daemon restart: link has been stable since, and contacts list/sync then fail fast with daemon error: unknown command. So this is purely the contacts request/response path.

Happy to capture a packet-level trace or test a patch (e.g. log-and-skip on unmarshal failure instead of disconnecting).

ekollof avatar Sep 16 '26 16:09 ekollof

Thanks for the great report, i was able to recreate locally.

the issue was the protocol buffer used across all plugins had a limit 4096B (4 kb) (most plugins never used more than this)

so synchronizing more than 50 contacts would cause the crash.

the issue has been fixed together with the daemon version issue, i will be releasing it as 1.18.2

bethropolis avatar Sep 16 '26 20:09 bethropolis

Phone side details (via adb): Pixel 10a, KDE Connect Android 1.35.16 (versionCode 13516), protocol 8. App process alive and listening on 1716 throughout.

ekollof avatar Sep 16 '26 20:09 ekollof

Confirmed fixed on real hardware with 1.19.0 (Pixel 10a, KDE Connect Android 1.35.16): contacts = false removed, sync round-trips cleanly, 141 contacts cached over contacts list --json, link stays up. Thanks for the quick turnaround.

ekollof avatar Sep 19 '26 16:09 ekollof