Skip to content

Commit a3561d3

Browse files
committed
ensure that xtrigger or fails
1 parent d5ac2e2 commit a3561d3

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

changes.d/6772.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prevent validation accepting two xtriggers with an | between them

cylc/flow/graph_parser.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ class GraphParser:
186186

187187
# Match @xtriggers.
188188
REC_XTRIG = re.compile(r'@[\w\-+%]+')
189+
REC_XTRIG_OR = re.compile(r'@.*\s*\|\s*@.*')
189190

190191
# Match fully qualified parameterized single nodes.
191192
REC_NODE_FULL = re.compile(
@@ -577,11 +578,14 @@ def _proc_dep_pair(
577578
if '' in lefts or left and not all(lefts):
578579
raise GraphParseError(
579580
f"Null task name in graph: {left} => {right}")
580-
581581
_rights.update(*([rights] or []))
582582

583583
for left in lefts:
584584
# Extract information about all nodes on the left.
585+
if left and self.REC_XTRIG_OR.match(left):
586+
raise GraphParseError(
587+
"'|' operator is not supported between xtriggers.")
588+
585589
if left:
586590
info = self.__class__.REC_NODES.findall(left)
587591
expr = left

tests/integration/test_config.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
WorkflowConfigError,
3131
XtriggerConfigError,
3232
)
33+
from cylc.flow.graph_parser import GraphParseError
3334
from cylc.flow.parsec.exceptions import ListValueError
3435
from cylc.flow.pathutil import get_workflow_run_pub_db_path
3536

@@ -488,6 +489,32 @@ def test_xtrig_signature_validation(
488489
validate(id_)
489490

490491

492+
def test_xtrig_or_fails_validation(
493+
flow: "Fixture",
494+
validate: "Fixture",
495+
):
496+
"""Xtriggers cannot be chained with the 'or'
497+
498+
https://github.com/cylc/cylc-flow/issues/6771
499+
https://github.com/cylc/cylc-flow/issues/2712
500+
"""
501+
id_ = flow(
502+
{
503+
"scheduling": {
504+
"initial cycle point": "2024",
505+
"xtriggers": {
506+
"xrandom": "xrandom(100)",
507+
"echo": "echo(succeed=True)"
508+
},
509+
"graph": {"R1": "@xrandom | @echo => foo"},
510+
}
511+
}
512+
)
513+
expected_msg = "'|' operator is not supported between xtriggers."
514+
with pytest.raises(GraphParseError, match=expected_msg):
515+
validate(id_)
516+
517+
491518
def test_special_task_non_word_names(flow: Fixture, validate: Fixture):
492519
"""Test validation of special tasks names with non-word characters"""
493520
wid = flow({

0 commit comments

Comments
 (0)