Skip to content

Commit 97b669b

Browse files
committed
fix: error on duplicate node labels in mkconcore and validate
1 parent 0467ce5 commit 97b669b

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

concore_cli/commands/validate.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,14 @@ def finalize():
117117
warnings.append(f"Node {node_id} has no label")
118118
except Exception as e:
119119
warnings.append(f"Error parsing node: {str(e)}")
120-
120+
121+
# duplicate labels cause silent corruption in mkconcore.py (#384)
122+
seen = set()
123+
for label in node_labels:
124+
if label in seen:
125+
errors.append(f"Duplicate node label: '{label}'")
126+
seen.add(label)
127+
121128
node_ids = {node.get('id') for node in nodes if node.get('id')}
122129
for edge in edges:
123130
source = edge.get('source')

mkconcore.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,12 @@ def cleanup_script_files():
307307
except (IndexError, AttributeError):
308308
logging.debug('A node with no valid properties encountered and ignored')
309309

310+
label_values = list(nodes_dict.values())
311+
duplicates = {label for label in label_values if label_values.count(label) > 1}
312+
if duplicates:
313+
logging.error(f"Duplicate node labels found: {sorted(duplicates)}")
314+
quit()
315+
310316
for edge in edges_text:
311317
try:
312318
data = edge.find('data', recursive=False)

0 commit comments

Comments
 (0)