Skip to content

Commit 98b5c91

Browse files
committed
handle any non utf8 payloads
just replace unknown utf8 characters to pre preserve the presence of a message Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
1 parent e5de3b1 commit 98b5c91

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tests/RobotFramework/libraries/ThinEdgeIO/ThinEdgeIO.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ def _assert_mqtt_topic_messages(
501501
)
502502

503503
messages = [
504-
bytes.fromhex(item["payload_hex"]).decode("utf8")
505-
# item["message"]["payload"]
504+
bytes.fromhex(item["payload_hex"]).decode("utf8", errors="replace")
506505
for item in items
507506
]
508507

@@ -525,7 +524,7 @@ def log_mqtt_messages(self, topic: str = "#", date_from: Union[datetime, float]
525524
**kwargs,
526525
)
527526
entries = [
528-
f'{item["message"]["tst"].replace("+0000", ""):32} {item["message"]["topic"]:70} {bytes.fromhex(item["payload_hex"]).decode("utf8")}'
527+
f'{item["message"]["tst"].replace("+0000", ""):32} {item["message"]["topic"]:70} {bytes.fromhex(item["payload_hex"]).decode("utf8", errors="replace")}'
529528
for item in items
530529
]
531530
log.info("---- mqtt messages ----\n%s", "\n".join(entries))

0 commit comments

Comments
 (0)