common-workflow-language / common-workflow-language/cwltool
Error with conditional step and input `loadContents`
- Dominant language
- Python
- Stars
- 376
- Forks
- 255
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 12
Description
I encountered a potential bug when running a workflow with two consecutive steps, where the steps are executed conditionally:
- Step 1 generates a file.
- Step 2 takes in input the output of Step 1 and loads the contents of the file.
When the condition is `true`, everything works as expected.
However, when Step 1 is skipped, and its output is `null`, an error occurs during the execution of Step 2 (even if also it is skipped).
It seems that Step 2 attempts to process the file even though it was not generated by Step 1, resulting in an error.
## Reproduction error:
Here’s a minimal example to reproduce the error. It shows the definition of Step 2.
`main.cwl`
```
cwlVersion: v1.2
class: Workflow
requirements:
InlineJavascriptRequirement: {}
inputs:
myfile: File?
outputs:
prov:
type: string?
outputSource: fst/res
steps:
fst:
in:
myfile: myfile
out: [res]
when: "$(inputs.myfile !== null)"
run:
class: CommandLineTool
requirements:
InitialWorkDirRequirement:
listing:
- entry: $(inputs.myfile)
baseCommand: ["ls"]
inputs:
myfile:
type: File
loadContents: true
stdout: res.out
outputs:
res:
type: string
outputBinding:
loadContents: true
glob: 'res.out'
outputEval: $(self[0].contents)
```
`config.yml`
```
myfile: null
```
### Log and error
```
INFO [workflow ] start
INFO [workflow ] starting step fst
ERROR Unhandled exception
Traceback (most recent call last):
File "/home/ubuntu/Repositories/cwltool/cwltool/workflow_job.py", line 730, in try_make_job
inputobj = postScatterEval(inputobj)
File "/home/ubuntu/Repositories/cwltool/cwltool/workflow_job.py", line 638, in postScatterEval
if val.get("contents") is None:
AttributeError: 'NoneType' object has no attribute 'get'
INFO [workflow ] completed permanentFail
WARNING Final process status is permanentFail
{
"prov": null
}
```
### Environment:
cwltool: 3.1.20251031082601
Contributor guide
Research direction
Start in cwltool/workflow_job.py at try_make_job and postScatterEval around line 638, then run the supplied main.cwl with config.yml where myfile is null. Confirm that the conditionally skipped steps complete without the NoneType error and that the workflow still reports prov as null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100