Skip to content

Commit 10749bb

Browse files
authored
Merge pull request #593 from bhuvan-somisetty/fix/validate-missing-label-node-id
fix(validate): return correct node_id for nodes without a label
2 parents 88edf27 + 382650a commit 10749bb

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎concore_cli/commands/validate.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _build_entries(bucket_name, messages, source_nodes):
9191
if node_id:
9292
entry["node_id"] = node_id
9393
elif message.startswith("Node ") and message.endswith(" has no label"):
94-
entry["node_id"] = message[5:-9]
94+
entry["node_id"] = message[5 : -len(" has no label")]
9595
elif message.startswith("Edge references non-existent source node:"):
9696
entry["node_id"] = message.split(":", 1)[1].strip()
9797
elif message.startswith("Edge references non-existent target node:"):

‎tests/test_cli.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,32 @@ def test_validate_json_output_for_missing_source_file(self):
139139
self.assertEqual(payload["errors"][0]["error_type"], "missing_source_file")
140140
self.assertEqual(payload["errors"][0]["node_id"], "n1")
141141

142+
def test_validate_json_output_for_node_without_label(self):
143+
with self.runner.isolated_filesystem(temp_dir=self.temp_dir):
144+
Path("src").mkdir()
145+
Path("workflow.graphml").write_text(
146+
"""<?xml version="1.0" encoding="UTF-8"?>
147+
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:y="http://www.yworks.com/xml/graphml">
148+
<graph id="G" edgedefault="directed">
149+
<node id="n1"></node>
150+
</graph>
151+
</graphml>
152+
"""
153+
)
154+
155+
result = self.runner.invoke(
156+
cli, ["validate", "workflow.graphml", "--format", "json"]
157+
)
158+
159+
payload = json.loads(result.output)
160+
warning = next(
161+
w
162+
for w in payload["warnings"]
163+
if w["error_type"] == "missing_node_label"
164+
)
165+
self.assertEqual(warning["node_id"], "n1")
166+
self.assertEqual(payload["summary"]["nodes_affected"], ["n1"])
167+
142168
def test_status_command(self):
143169
result = self.runner.invoke(cli, ["status"])
144170
self.assertEqual(result.exit_code, 0)

0 commit comments

Comments
 (0)