Skip to content

Commit

Permalink
handle any non utf8 payloads
Browse files Browse the repository at this point in the history
just replace unknown utf8 characters to pre preserve the presence of a message

Signed-off-by: Reuben Miller <[email protected]>
  • Loading branch information
reubenmiller committed Nov 6, 2023
1 parent e5de3b1 commit 98b5c91
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/RobotFramework/libraries/ThinEdgeIO/ThinEdgeIO.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ def _assert_mqtt_topic_messages(
)

messages = [
bytes.fromhex(item["payload_hex"]).decode("utf8")
# item["message"]["payload"]
bytes.fromhex(item["payload_hex"]).decode("utf8", errors="replace")
for item in items
]

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

0 comments on commit 98b5c91

Please sign in to comment.