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

Type mismatched `default` value is accidentally accepted

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

Description

`cwltool --validate` accidentally accepts CWL documents in which `default` value is mismatched with the type specified in `type` field.
Is this a bug of `cwltool` or are there any descriptions in the spec that support this behavior?

```console
$ cwltool --validate sample.cwl
```

## Expected Behavior
Validation fails due to type mismatched field. For example:
```console
$ cwltool --validate sample.cwl
...
ERROR Tool definition failed validation:
sample.cwl:2:1: Object `sample.cwl` is not valid because
tried `CommandLineTool` but
sample.cwl:5:1: the `inputs` field is not valid because
sample.cwl:6:5: item is invalid because
sample.cwl:8:9: the `default` is not valid because
tried string but
the value is not string
```

## Actual Behavior
It accidentally passes the validation of `cwltool`.
```console
$ cwltool --validate sample.cwl
...
sample.cwl is valid CWL.
```

## Workflow Code
sample.cwl:
```cwl
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: CommandLineTool
baseCommand: echo
inputs:
message:
type: string
default: 10
inputBinding: {}
outputs:
out: stdout
```

## Your Environment
* cwltool version:
Check using ``cwltool --version``

```console
$ cwltool --version
/home/tom-tan/.local/bin/cwltool 3.0.20210319143721
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.