Skip to content

Commit a283177

Browse files
authored
Merge pull request #426 from avinxshKD/fix/duplicate-node-label-v2
fix: error on duplicate node labels in mkconcore and validate
2 parents 7032308 + 4ebae6c commit a283177

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
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
@@ -309,6 +309,12 @@ def cleanup_script_files():
309309
except (IndexError, AttributeError):
310310
logging.debug('A node with no valid properties encountered and ignored')
311311

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

0 commit comments

Comments
 (0)