diff --git a/concore_cli/commands/validate.py b/concore_cli/commands/validate.py index a7168b3..b2582d7 100644 --- a/concore_cli/commands/validate.py +++ b/concore_cli/commands/validate.py @@ -91,7 +91,7 @@ def _build_entries(bucket_name, messages, source_nodes): if node_id: entry["node_id"] = node_id elif message.startswith("Node ") and message.endswith(" has no label"): - entry["node_id"] = message[5:-9] + entry["node_id"] = message[5 : -len(" has no label")] elif message.startswith("Edge references non-existent source node:"): entry["node_id"] = message.split(":", 1)[1].strip() elif message.startswith("Edge references non-existent target node:"): diff --git a/tests/test_cli.py b/tests/test_cli.py index d746040..2d4c712 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -123,6 +123,32 @@ def test_validate_json_output_for_missing_source_file(self): self.assertEqual(payload["errors"][0]["error_type"], "missing_source_file") self.assertEqual(payload["errors"][0]["node_id"], "n1") + def test_validate_json_output_for_node_without_label(self): + with self.runner.isolated_filesystem(temp_dir=self.temp_dir): + Path("src").mkdir() + Path("workflow.graphml").write_text( + """ + + + + + +""" + ) + + result = self.runner.invoke( + cli, ["validate", "workflow.graphml", "--format", "json"] + ) + + payload = json.loads(result.output) + warning = next( + w + for w in payload["warnings"] + if w["error_type"] == "missing_node_label" + ) + self.assertEqual(warning["node_id"], "n1") + self.assertEqual(payload["summary"]["nodes_affected"], ["n1"]) + def test_status_command(self): result = self.runner.invoke(cli, ["status"]) self.assertEqual(result.exit_code, 0)