From a8acb7a83bfc16d7946ef8c662ca8241159c3bee Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Mon, 3 Jun 2024 21:49:26 +0200 Subject: [PATCH] Don't fail when encountering invalid strings (#733) --- matter_server/client/client.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/matter_server/client/client.py b/matter_server/client/client.py index 64d133c4..624eaa30 100644 --- a/matter_server/client/client.py +++ b/matter_server/client/client.py @@ -358,7 +358,9 @@ async def node_diagnostics(self, node_id: int) -> NodeDiagnostics: 0, Clusters.ThreadNetworkDiagnostics ) if isinstance(thread_cluster.networkName, bytes): - network_name = thread_cluster.networkName.decode("utf-8") + network_name = thread_cluster.networkName.decode( + "utf-8", errors="replace" + ) elif thread_cluster.networkName != NullValue: network_name = thread_cluster.networkName # parse routing role to (diagnostics) node type @@ -390,7 +392,7 @@ async def node_diagnostics(self, node_id: int) -> NodeDiagnostics: ) ): if isinstance(last_network_id, bytes): - network_name = last_network_id.decode("utf-8") + network_name = last_network_id.decode("utf-8", errors="replace") elif last_network_id != NullValue: network_name = last_network_id # last resort to get the (wifi) networkname; @@ -407,7 +409,7 @@ async def node_diagnostics(self, node_id: int) -> NodeDiagnostics: if not network.connected: continue if isinstance(network.networkID, bytes): - network_name = network.networkID.decode("utf-8") + network_name = network.networkID.decode("utf-8", errors="replace") break if network.networkID != NullValue: network_name = network.networkID