From b54f9fdd8a32e251777bdcb4bf76a55dcd011608 Mon Sep 17 00:00:00 2001 From: octo-patch Date: Mon, 20 Apr 2026 09:19:23 +0800 Subject: [PATCH] fix: skip relationships with invalid indices instead of crashing (fixes #161) --- nodes.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/nodes.py b/nodes.py index 0e3fa587..04993638 100644 --- a/nodes.py +++ b/nodes.py @@ -379,21 +379,23 @@ def exec(self, prep_res): try: from_idx = int(str(rel["from_abstraction"]).split("#")[0].strip()) to_idx = int(str(rel["to_abstraction"]).split("#")[0].strip()) - if not ( - 0 <= from_idx < num_abstractions and 0 <= to_idx < num_abstractions - ): - raise ValueError( - f"Invalid index in relationship: from={from_idx}, to={to_idx}. Max index is {num_abstractions-1}." - ) - validated_relationships.append( - { - "from": from_idx, - "to": to_idx, - "label": rel["label"], # Potentially translated label - } - ) except (ValueError, TypeError): - raise ValueError(f"Could not parse indices from relationship: {rel}") + print(f"Warning: Could not parse indices from relationship, skipping: {rel}") + continue + if not ( + 0 <= from_idx < num_abstractions and 0 <= to_idx < num_abstractions + ): + print( + f"Warning: Invalid index in relationship (from={from_idx}, to={to_idx}, max={num_abstractions-1}), skipping." + ) + continue + validated_relationships.append( + { + "from": from_idx, + "to": to_idx, + "label": rel["label"], # Potentially translated label + } + ) print("Generated project summary and relationship details.") return {