From 1a3a1e937ce24f3de43e14ec68e2861f5339d75a Mon Sep 17 00:00:00 2001 From: MarekWo Date: Sat, 7 Mar 2026 07:32:56 +0100 Subject: [PATCH] fix(dm): clear error when contact not on device, log error_code detail Device firmware requires contacts in its table to send DMs. Passing a raw pubkey string results in error_code=2. Show actionable error message instead of generic "Device error". Co-Authored-By: Claude Opus 4.6 --- app/device_manager.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/device_manager.py b/app/device_manager.py index a7acb07..adb78d1 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -827,14 +827,15 @@ class DeviceManager: return {'success': False, 'error': 'Device not connected'} try: - # Find contact dict from mc.contacts (used for retry/path info) - # send_msg() also accepts a hex pubkey string directly + # Find contact in device's contact table contact = self.mc.contacts.get(recipient_pubkey) if not contact: contact = self.mc.get_contact_by_key_prefix(recipient_pubkey) if not contact: - # Use pubkey string directly — meshcore lib handles it - contact = recipient_pubkey + # Contact must exist on device to send DM + return {'success': False, + 'error': f'Contact not on device. ' + f'Re-add {recipient_pubkey[:12]}... via Contacts page.'} # Generate timestamp once — same for all retries (enables receiver dedup) timestamp = int(time.time())