mirror of
https://github.com/meshcore-dev/meshcore_py.git
synced 2026-11-02 10:41:59 +00:00
Do not raise KeyError copying an undecryptable channels_log entry
parsePacketPayload copies message/msg_hash/sender_timestamp/attempt/txt_type from a prior channels_log entry matched by pkt_hash. When that prior entry was logged while the channel could not be decrypted it has none of those keys, so a later duplicate of the same transmission raises KeyError: 'message' and aborts handle_rx for the whole packet, dropping its RX_LOG_DATA. It triggers when a channel-table refresh lands between two copies of a flooded channel message. Copy with .get() so the fields are simply absent instead of raising. Adds a regression test that reproduces the crash (fails on main, passes here).
This commit is contained in:
@@ -160,11 +160,15 @@ class MeshcorePacketParser:
|
||||
log_data["txt_type"] = txt_type
|
||||
else:
|
||||
# found: copy
|
||||
log_data["message"] = logged["message"]
|
||||
log_data["msg_hash"] = logged["msg_hash"]
|
||||
log_data["sender_timestamp"] = logged["sender_timestamp"]
|
||||
log_data["attempt"] = logged["attempt"]
|
||||
log_data["txt_type"] = logged["txt_type"]
|
||||
# A prior channels_log entry matched by pkt_hash may have been logged while the
|
||||
# channel could not be decrypted, so it has no "message"/"msg_hash"/etc. Copy with
|
||||
# .get() so a duplicate of an unreadable frame does not raise KeyError and abort
|
||||
# handle_rx for the whole packet.
|
||||
log_data["message"] = logged.get("message")
|
||||
log_data["msg_hash"] = logged.get("msg_hash")
|
||||
log_data["sender_timestamp"] = logged.get("sender_timestamp")
|
||||
log_data["attempt"] = logged.get("attempt")
|
||||
log_data["txt_type"] = logged.get("txt_type")
|
||||
|
||||
self.channels_log.append(log_data)
|
||||
if len(self.channels_log) > 100:
|
||||
|
||||
Reference in New Issue
Block a user