Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messages: enforce unique task messages #6235

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cylc/flow/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2434,9 +2434,18 @@
raise WorkflowConfigError(str(exc))
else:
# Record custom message outputs from [runtime].
messages = set(self.cfg['runtime'][name]['outputs'].values())
for output, message in (
self.cfg['runtime'][name]['outputs'].items()
):
try:
messages.remove(message)
except KeyError:
raise WorkflowConfigError(

Check warning on line 2444 in cylc/flow/config.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/config.py#L2443-L2444

Added lines #L2443 - L2444 were not covered by tests
'Duplicate task message in'
f' "[runtime][{name}][outputs]'
f'{output} = {message}" - messages must be unique'
)
valid, msg = TaskOutputValidator.validate(output)
if not valid:
raise WorkflowConfigError(
Expand Down
34 changes: 34 additions & 0 deletions tests/integration/validate/test_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,37 @@ def test_completion_expression_cylc7_compat(
match="completion cannot be used in Cylc 7 compatibility mode."
):
validate(id_)


def test_unique_messages(
flow,
validate
):
"""Task messages must be unique in the [outputs] section.

See: https://github.com/cylc/cylc-flow/issues/6056
"""
id_ = flow({
'scheduling': {
'graph': {'R1': 'foo'}
},
'runtime': {
'foo': {
'outputs': {
'a': 'foo',
'b': 'bar',
'c': 'baz',
'd': 'foo',
}
},
}
})

with pytest.raises(
WorkflowConfigError,
match=(
r'"\[runtime\]\[foo\]\[outputs\]d = foo"'
' - messages must be unique'
),
):
validate(id_)
Loading