I recently noticed a mistake in one of my workflows. Whilst it was easily fixed, it made me wonder if cwltool’s validation correctly checks inputs in conditional expressions.
Consider the following example:
$ cat $PWD/test.cwl
cwlVersion: v1.2
class: Workflow
requirements:
InlineJavascriptRequirement: {}
inputs:
bool:
type: boolean?
default: false
outputs: []
steps:
step:
in: []
out: []
run:
cwlVersion: v1.2
class: CommandLineTool
baseCommand: whoami
inputs: []
outputs: []
when: $(inputs.bool)
The standard say the following on Conditional Execution:
The
when
field controls conditional execution. This is an expression that must be evaluated withinputs
bound to the step input object (or individual scatter job), and returns a boolean value.
In the example above, the input bool
isn’t bound to the inputs of step step
, so naively I would expect that this workflow is invalid. However, the validation passes:
$ cwltool --validate test.cwl
INFO /home/me/.local/bin/cwltool 3.1.20240508115724
INFO Resolved 'test.cwl' to 'file:///home/me/test.cwl'
test.cwl is valid CWL.
The workflow then results in a runtime error when the condition is checked. Is this expected behaviour, or should the validation fail?
Generally, these conditions cannot be evaluated ahead of the execution of the workflow, but would it be possible to at least check if all inputs have been properly passed to the step?