From 950663f456acf5d53cde951d1e021b41d1b2b33f Mon Sep 17 00:00:00 2001 From: Oide Brett <32061073+oidebrett@users.noreply.github.com> Date: Tue, 18 Jun 2024 09:54:50 +0100 Subject: [PATCH] Edge case defect when importing the first test node into dashboard (#763) --- matter_server/server/device_controller.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/matter_server/server/device_controller.py b/matter_server/server/device_controller.py index d466a423..c4cb34a8 100644 --- a/matter_server/server/device_controller.py +++ b/matter_server/server/device_controller.py @@ -865,7 +865,12 @@ async def import_test_node(self, dump: str) -> None: else: dump_nodes = dump_data["data"]["server"]["nodes"] # node ids > 900000 are reserved for test nodes - next_test_node_id = max(*(x for x in self._nodes), TEST_NODE_START) + 1 + if self._nodes: + next_test_node_id = max(*(x for x in self._nodes), TEST_NODE_START) + 1 + else: + # an empty self._nodes dict evaluates to false so we set the first + # test node id to TEST_NODE_START + next_test_node_id = TEST_NODE_START for node_dict in dump_nodes: node = dataclass_from_dict(MatterNodeData, node_dict, strict=True) node.node_id = next_test_node_id