From af7466351848337211e3bafa6958e4389742bbf1 Mon Sep 17 00:00:00 2001 From: Jack Kingsman Date: Mon, 6 Apr 2026 20:12:58 -0700 Subject: [PATCH] Add guard for favorites sync --- app/radio_sync.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/radio_sync.py b/app/radio_sync.py index 467fbb3..cdedc31 100644 --- a/app/radio_sync.py +++ b/app/radio_sync.py @@ -1070,8 +1070,15 @@ async def sync_contacts_from_radio(mc: MeshCore) -> dict: logger.debug("Synced %d contacts from radio snapshot", synced) - # Import radio-favorited contacts into app favorites - radio_fav_keys = [pk for pk, data in contacts.items() if data.get("flags", 0) & 0x01] + # Import radio-favorited contacts into app favorites. + # Only trust the favorite bit on contacts with a valid type (0-4); + # garbled radio data can have junk flags with bit 0 set. + _VALID_CONTACT_TYPES = {0, 1, 2, 3, 4} + radio_fav_keys = [ + pk + for pk, data in contacts.items() + if data.get("flags", 0) & 0x01 and data.get("type", -1) in _VALID_CONTACT_TYPES + ] if radio_fav_keys: try: imported = 0