diff --git a/cylc/flow/config.py b/cylc/flow/config.py index 5b7738f3e6c..d29537ce7ab 100644 --- a/cylc/flow/config.py +++ b/cylc/flow/config.py @@ -2434,9 +2434,18 @@ def get_taskdef( 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( + '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( diff --git a/tests/integration/validate/test_outputs.py b/tests/integration/validate/test_outputs.py index b26bce529fb..1a8177cd35b 100644 --- a/tests/integration/validate/test_outputs.py +++ b/tests/integration/validate/test_outputs.py @@ -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_)