From 1e508a363610eb6555867dd9144bbf18e47dfb14 Mon Sep 17 00:00:00 2001 From: Matthew Wolter Date: Sat, 11 Apr 2026 20:03:49 -0700 Subject: [PATCH] =?UTF-8?q?G2:=20F21/M01=20=E2=80=94=20fix=20send=5Fmsg=5F?= =?UTF-8?q?with=5Fretry=20fallthrough=20to=20KeyError=20on=20ERROR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why: When send_msg() returned an ERROR event (e.g. firmware rejected the send), the error-check logged the failure but did not return or continue. Execution fell through to result.payload["expected_ack"], which raised KeyError because the ERROR payload is {"reason": "..."}. The retry loop — the entire purpose of this function — never ran. Now the ERROR path increments attempt counters and continues the loop, preserving the retry semantics the function name promises. Refs: Forensics report findings F21, M01 --- src/meshcore/commands/messaging.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/meshcore/commands/messaging.py b/src/meshcore/commands/messaging.py index b266ae0..b821ea0 100644 --- a/src/meshcore/commands/messaging.py +++ b/src/meshcore/commands/messaging.py @@ -144,8 +144,12 @@ class MessagingCommands(CommandHandlerBase): logger.info(f"Retry sending msg: {attempts + 1}") result = await self.send_msg(dst, msg, timestamp, attempt=attempts) - if result.type == EventType.ERROR: - logger.error(f"⚠️ Failed to send message: {result.payload}") + if result.is_error(): + logger.error(f"Failed to send message: {result.payload}") + attempts += 1 + if flood: + flood_attempts += 1 + continue exp_ack = result.payload["expected_ack"].hex() timeout = result.payload["suggested_timeout"] / 1000 * 1.2 if timeout==0 else timeout @@ -255,7 +259,7 @@ class MessagingCommands(CommandHandlerBase): elif path_hash_len == 8 : flags = 3 else : - logger.error(f"Invalid path format: {e}") + logger.error(f"Invalid path format: unknown path_hash_len {path_hash_len}") return Event(EventType.ERROR, {"reason": "invalid_path_format"}) else: flags = 0