mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-04-20 22:13:49 +00:00
G2: F21/M01 — fix send_msg_with_retry fallthrough to KeyError on ERROR
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
This commit is contained in:
parent
6a74f07da7
commit
1e508a3636
1 changed files with 7 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue