Skip to content

Commit d7a74eb

Browse files
author
Anton Khodak
authored
Merge pull request #635 from common-workflow-language/fix/unsupported-operands
Fix type mismatches that caused bad error messages
2 parents 4482257 + 130f3b9 commit d7a74eb

File tree

5 files changed

+52
-1
lines changed

5 files changed

+52
-1
lines changed

cwltool/builder.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ def generate_arg(self, binding): # type: (Dict[Text,Any]) -> List[Text]
217217

218218
prefix = binding.get("prefix")
219219
sep = binding.get("separate", True)
220+
if prefix is None and not sep:
221+
with SourceLine(binding, "separate", WorkflowException, _logger.isEnabledFor(logging.DEBUG)):
222+
raise WorkflowException("'separate' option can not be specified without prefix")
220223

221224
l = [] # type: List[Dict[Text,Text]]
222225
if isinstance(value, list):

cwltool/load_tool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from avro.schema import Names
2121
from ruamel.yaml.comments import CommentedMap, CommentedSeq
2222
from schema_salad.ref_resolver import ContextType, Fetcher, Loader, file_uri
23-
from schema_salad.sourceline import cmap
23+
from schema_salad.sourceline import cmap, SourceLine
2424
from schema_salad.validate import ValidationException
2525

2626
from . import process, update
@@ -124,6 +124,9 @@ def _convert_stdstreams_to_files(workflowobj):
124124
if isinstance(workflowobj, dict):
125125
if workflowobj.get('class') == 'CommandLineTool':
126126
for out in workflowobj.get('outputs', []):
127+
if type(out) is not CommentedMap:
128+
with SourceLine(workflowobj, "outputs", ValidationException, _logger.isEnabledFor(logging.DEBUG)):
129+
raise ValidationException("Output '%s' is not a valid OutputParameter." % out)
127130
for streamtype in ['stdout', 'stderr']:
128131
if out.get('type') == streamtype:
129132
if 'outputBinding' in out:

tests/test_examples.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from io import StringIO
99

10+
from cwltool.errors import WorkflowException
1011
from cwltool.utils import onWindows
1112

1213
try:
@@ -525,6 +526,20 @@ def test_lifting(self):
525526
echo = f.make(get_data("tests/test_bad_outputs_wf.cwl"))
526527
self.assertEqual(echo(inp="foo"), {"out": "foo\n"})
527528

529+
def test_malformed_outputs(self):
530+
# check that tool validation fails if one of the outputs is not a valid CWL type
531+
f = cwltool.factory.Factory()
532+
with self.assertRaises(schema_salad.validate.ValidationException):
533+
echo = f.make(get_data("tests/wf/malformed_outputs.cwl"))
534+
echo()
535+
536+
def test_separate_without_prefix(self):
537+
# check that setting 'separate = false' on an inputBinding without prefix fails the workflow
538+
with self.assertRaises(WorkflowException):
539+
f = cwltool.factory.Factory()
540+
echo = f.make(get_data("tests/wf/separate_without_prefix.cwl"))
541+
echo()
542+
528543

529544
def test_checker(self):
530545
# check that the static checker raises exception when a source type

tests/wf/malformed_outputs.cwl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
baseCommand: echo
4+
5+
inputs:
6+
[]
7+
outputs:
8+
-

tests/wf/separate_without_prefix.cwl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
baseCommand: echo
4+
5+
inputs:
6+
src:
7+
type: string
8+
default:
9+
string
10+
inputBinding:
11+
position: 1
12+
separate: false
13+
14+
stdout: output.txt
15+
16+
outputs:
17+
output:
18+
type: string
19+
outputBinding:
20+
glob: output.txt
21+
loadContents: true
22+
outputEval: $(self[0].contents)

0 commit comments

Comments
 (0)