Skip to content

Error with conditional step and input loadContents #2182

@LanderOtto

Description

@LanderOtto

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions