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

cwltool fails to emit error when ExpressionTool expression does not match expected output format

Open
#1,026 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
An error message should be emitted and `cwltool` should fail the workflow when the expression for an ExpressionTool is invalid for the expected output. Per section 4.2.13 of the CWL specification:

> `expression` - The expression to execute. The expression must return a JSON object which matches the output parameters of the ExpressionTool.

Note that the CWL specification isn't completely clear: The tool's name and the `expression` parameter suggest that the expression can be a `string` which will be evaluated as JavaScript, but examples from the CWL repo use _interpolated_ expressions i.e. `$()` and `${}` which suggests that ExpressionTool merely returns the expression (evaluated by the interpolation), rather than double evaluating it. If there's no explicit interpolation, then a bare `string` type cannot possible be a valid output, since an ExpressionTool's `output` is necessarily an _array or map_. Thus, I suspect there may be a bug in the CWL specifications.

## Actual Behavior
The `cwltool` erroneously succeeds, giving output that matches the structure of the expression in the ExpressionTool, even though it does *not* match the declared output structure.
```
{
"not_my_output": {
"my_input": "my_string"
}
}
Final process status is success
```

## Workflow Code
Sample CWL which takes a string input, evaluates a map (JSON object) that has `not_my_output` as the key and string as value, yet the declared output has key `out` and type `int` which does not match.

```
cwlVersion: v1.0
class: ExpressionTool
requirements:
- class: InlineJavascriptRequirement
expression: "$({'not_my_output':inputs})"
inputs:
my_input: string
outputs:
out:
type: int
```
```
my_input: my_string
```

## Full Traceback
No failure is emitted.

## Your Environment
* cwltool version: 1.0.20181129095638

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.