From 32b51530ece7654380f8137f72072179dccd8b1d Mon Sep 17 00:00:00 2001 From: Daniel Chalef <131175+danielchalef@users.noreply.github.com> Date: Fri, 20 Sep 2024 21:03:20 -0700 Subject: [PATCH] feat: Fix bug in dedupe_node_list function (#137) The code changes fix a bug in the `dedupe_node_list` function where a node instance was not found in the node map. The bug is now handled by logging a warning message and skipping the iteration. This ensures that the function continues to execute without any errors. --- graphiti_core/utils/maintenance/node_operations.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/graphiti_core/utils/maintenance/node_operations.py b/graphiti_core/utils/maintenance/node_operations.py index 2da68be1..cf2d644f 100644 --- a/graphiti_core/utils/maintenance/node_operations.py +++ b/graphiti_core/utils/maintenance/node_operations.py @@ -272,9 +272,12 @@ async def dedupe_node_list( unique_nodes = [] uuid_map: dict[str, str] = {} for node_data in nodes_data: - node = node_map[node_data['uuids'][0]] - node.summary = node_data['summary'] - unique_nodes.append(node) + node_instance: EntityNode | None = node_map.get(node_data['uuids'][0]) + if node_instance is None: + logger.warning(f'Node {node_data["uuids"][0]} not found in node map') + continue + node_instance.summary = node_data['summary'] + unique_nodes.append(node_instance) for uuid in node_data['uuids'][1:]: uuid_value = node_map[node_data['uuids'][0]].uuid