mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-13 08:15:21 +02:00
Merge e3c08209bb into 97d7103480
This commit is contained in:
commit
c88abcd954
2 changed files with 35 additions and 2 deletions
|
|
@ -127,8 +127,7 @@ def validate_trigger_paths(
|
|||
)
|
||||
)
|
||||
|
||||
first_node_id = seen_paths.get(trigger_path)
|
||||
if first_node_id is None:
|
||||
if trigger_path not in seen_paths:
|
||||
seen_paths[trigger_path] = node_id
|
||||
else:
|
||||
issues.append(
|
||||
|
|
|
|||
|
|
@ -54,3 +54,37 @@ def test_validate_trigger_paths_rejects_long_and_duplicate_paths():
|
|||
in messages
|
||||
)
|
||||
assert "Trigger path is duplicated in this workflow." in messages
|
||||
|
||||
|
||||
def test_validate_trigger_paths_detects_duplicate_when_first_node_has_no_id():
|
||||
"""A duplicate trigger path must be flagged even when the first node sharing
|
||||
that path has no ``id`` (``node.get("id")`` is None).
|
||||
|
||||
Regression: the duplicate check previously used ``seen_paths.get(path)`` and
|
||||
treated a ``None`` result as "not seen yet", so a first node with a missing
|
||||
id (stored as None) made every later node with the same path slip through
|
||||
undetected.
|
||||
"""
|
||||
workflow_definition = {
|
||||
"nodes": [
|
||||
# No "id" key -> node_id resolves to None.
|
||||
{"type": "trigger", "data": {"trigger_path": "sales_agent"}},
|
||||
{
|
||||
"id": "trigger-2",
|
||||
"type": "trigger",
|
||||
"data": {"trigger_path": "sales_agent"},
|
||||
},
|
||||
],
|
||||
"edges": [],
|
||||
}
|
||||
|
||||
issues = validate_trigger_paths(workflow_definition)
|
||||
messages = [issue.message for issue in issues]
|
||||
|
||||
assert "Trigger path is duplicated in this workflow." in messages
|
||||
duplicate_issue = next(
|
||||
issue
|
||||
for issue in issues
|
||||
if issue.message == "Trigger path is duplicated in this workflow."
|
||||
)
|
||||
assert duplicate_issue.node_id == "trigger-2"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue