common-workflow-language / common-workflow-language/cwltool

cwltool throws an error when `secondaryFile`s are specified as a list in a workflow and as a single element in a tool

Open
#1,912 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
376
Forks
255
Avg merge
2d 7h
Merged PRs (30d)
12

Description

## Expected Behavior
No error should be thrown

## Actual Behavior
An error is thrown

## Workflow Code
`workflow.cwl`
```
cwlVersion: v1.2
class: Workflow

inputs:
file:
type: File
secondaryFiles:
- .csi

steps:
- id: run tool
run: tool.cwl
in:
file: file
out: []

outputs: []
```
`tool.cwl`
```
cwlVersion: v1.2
class: CommandLineTool

inputs:
file:
type: File
secondaryFiles: .csi

outputs: []
```

## Full Traceback
```pytb
$ cwltool --debug --validate ./workflow.cwl
INFO /home/user/Documents/checkouts/cwltool/venv/bin/cwltool 3.1.20230630061538
INFO Resolved './workflow.cwl' to 'file:///home/user/test-folder/workflow.cwl'
ERROR I'm sorry, I couldn't load this CWL file.
The error was:
Traceback (most recent call last):
File "/home/user/Documents/checkouts/cwltool/cwltool/main.py", line 1119, in main
tool = make_tool(uri, loadingContext)
File "/home/user/Documents/checkouts/cwltool/cwltool/load_tool.py", line 588, in make_tool
tool = loadingContext.construct_tool_object(processobj, loadingContext)
File "/home/user/Documents/checkouts/cwltool/cwltool/workflow.py", line 55, in default_make_tool
return Workflow(toolpath_object, loadingContext)
File "/home/user/Documents/checkouts/cwltool/cwltool/workflow.py", line 137, in __init__
static_checker(
File "/home/user/Documents/checkouts/cwltool/cwltool/checker.py", line 211, in static_checker
sinksf = sorted(
File "/home/user/Documents/checkouts/cwltool/cwltool/checker.py", line 212, in
p["pattern"] for p in sink.get("secondaryFiles", []) if p.get("required", True)
AttributeError: 'str' object has no attribute 'get'

```

## Your Environment
* cwltool version:
Check using ``cwltool --version``
```
$ cwltool --version
/home/user/Documents/checkouts/cwltool/venv/bin/cwltool 3.1.20230630061538
```
(this is using the latest commit in main)

I think the cause of this is two-fold:
- The code that checks whether secondaryFiles are compatible warns even if the src and sink are the same, but one represented as an array, and one as a single value in `secondaryFiles`
- The code that reports this doesn't account for the fact that `secondaryFiles` properties may be an array or a single element

Contributor guide

Open the contributing guide

Research direction

Start with the static_checker call in cwltool/checker.py and the workflow construction path in cwltool/workflow.py, then reproduce the failure with the provided workflow.cwl and tool.cwl using cwltool --debug --validate. Done means validation accepts equivalent secondaryFiles represented as a list and a single element without raising the shown AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.