Skip to content

Commit

Permalink
Don't fail when encountering invalid strings (#733)
Browse files Browse the repository at this point in the history
  • Loading branch information
agners authored Jun 3, 2024
1 parent b497638 commit a8acb7a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions matter_server/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit a8acb7a

Please sign in to comment.