From 5eec424aef192a0a12ed64aa0df0945e11b9b056 Mon Sep 17 00:00:00 2001 From: Peter van Heusden Date: Tue, 24 Nov 2020 18:16:41 +0200 Subject: [PATCH 1/5] Address ambiguity on null and inputs.somearray.length in parameter reference --- concepts.md | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/concepts.md b/concepts.md index 3aa6c8dc..84416d11 100644 --- a/concepts.md +++ b/concepts.md @@ -510,17 +510,21 @@ or more repeats, and all other characters are literal values. Use the following algorithm to resolve a parameter reference: 1. Match the leading symbol as the key - 2. Look up the key in the parameter context (described below) to get the current value. + 2. If the key is the special value 'null' then the + value of the parameter reference is 'null'. If the key is 'null' it must be the only symbol in the parameter reference. + 3. Look up the key in the parameter context (described below) to get the current value. It is an error if the key is not found in the parameter context. - 3. If there are no subsequent segments, terminate and return current value - 4. Else, match the next segment - 5. Extract the symbol, string, or index from the segment as the key - 6. Look up the key in current value and assign as new current value. If - the key is a symbol or string, the current value must be an object. - If the key is an index, the current value must be an array or string. - It is an error if the key does not match the required type, or the key is not found or out - of range. - 7. Repeat steps 3-6 + 4. If there are no subsequent segments, terminate and return current value + 5. Else, match the next segment + 6. Extract the symbol, string, or index from the segment as the key + 7. Look up the key in current value and assign as new current value. + 1. If the key is a symbol or string, the current value must be an object. + 2. If the key is an index, the current value must be an array or string. + 3. If the last key is the special value 'length' the current value must be an array and the value + of the parameter reference is the length of the array. + 4. It is an error if the key does not match the required type, or the key is not found or out + of range. + 8. Repeat steps 3-6 The root namespace is the parameter context. The following parameters must be provided: From 75a5ac3a9a2931fa8e5971cbf4189beb09be5816 Mon Sep 17 00:00:00 2001 From: Peter van Heusden Date: Tue, 24 Nov 2020 19:45:03 +0200 Subject: [PATCH 2/5] Add tests for incorrect use of parameter references --- conformance_tests.yaml | 13 +++++++++++++ tests/params_broken_length_of_non_list.cwl | 14 ++++++++++++++ tests/params_broken_null.cwl | 14 ++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 tests/params_broken_length_of_non_list.cwl create mode 100644 tests/params_broken_null.cwl diff --git a/conformance_tests.yaml b/conformance_tests.yaml index f59d0e5e..465e56d6 100644 --- a/conformance_tests.yaml +++ b/conformance_tests.yaml @@ -3399,3 +3399,16 @@ - $import: tests/mixed-versions/test-index.yaml - $import: tests/loadContents/test-index.yaml - $import: tests/iwd/test-index.yaml + +- job: tests/empty.json + tool: tests/params_broken_null.cwl + label: params_broken_null + doc: Test parameter reference that refers to null.something + should_fail: true + tags: [ command_line_tool ] + +- job: tests/empty.json + tool: tests/params_broken_length_of_non_list.cwl + doc: Test paramer reference that refers to length of non-array input + should_fail: true + tags: [ command_line_tool ] diff --git a/tests/params_broken_length_of_non_list.cwl b/tests/params_broken_length_of_non_list.cwl new file mode 100644 index 00000000..267f3ca9 --- /dev/null +++ b/tests/params_broken_length_of_non_list.cwl @@ -0,0 +1,14 @@ +class: CommandLineTool +cwlVersion: v1.2 +inputs: + bar: + type: Any + default: 0 + +outputs: + output1: + type: Any + outputBinding: + outputEval: $(inputs.bar.length) + +baseCommand: "true" \ No newline at end of file diff --git a/tests/params_broken_null.cwl b/tests/params_broken_null.cwl new file mode 100644 index 00000000..15710f24 --- /dev/null +++ b/tests/params_broken_null.cwl @@ -0,0 +1,14 @@ +class: CommandLineTool +cwlVersion: v1.2 +inputs: + bar: + type: Any + default: "something" + +outputs: + output1: + type: "null" + outputBinding: + outputEval: $(null.something) + +baseCommand: "true" \ No newline at end of file From ede6dedd73e130d19fc066dc46863455f727adc3 Mon Sep 17 00:00:00 2001 From: Peter van Heusden Date: Tue, 24 Nov 2020 20:49:10 +0200 Subject: [PATCH 3/5] Fix steps 3-6 to 3-8 --- concepts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/concepts.md b/concepts.md index 84416d11..903804c3 100644 --- a/concepts.md +++ b/concepts.md @@ -524,7 +524,7 @@ Use the following algorithm to resolve a parameter reference: of the parameter reference is the length of the array. 4. It is an error if the key does not match the required type, or the key is not found or out of range. - 8. Repeat steps 3-6 + 8. Repeat steps 3-8 The root namespace is the parameter context. The following parameters must be provided: From fcf17b9c708b228c49ae09ce3bbc736942641dcd Mon Sep 17 00:00:00 2001 From: Peter van Heusden Date: Wed, 25 Nov 2020 07:27:16 +0200 Subject: [PATCH 4/5] Clarify that the length field can sometimes apply to a non-array input --- concepts.md | 6 ++-- conformance_tests.yaml | 9 ++++++ tests/length_non_array_input.yml | 5 ++++ tests/params_input_length_non_array.cwl | 40 +++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 tests/length_non_array_input.yml create mode 100644 tests/params_input_length_non_array.cwl diff --git a/concepts.md b/concepts.md index 903804c3..3e4f2117 100644 --- a/concepts.md +++ b/concepts.md @@ -520,8 +520,10 @@ Use the following algorithm to resolve a parameter reference: 7. Look up the key in current value and assign as new current value. 1. If the key is a symbol or string, the current value must be an object. 2. If the key is an index, the current value must be an array or string. - 3. If the last key is the special value 'length' the current value must be an array and the value - of the parameter reference is the length of the array. + 3. If the next key is the last key and it has the special value 'length' and + the current value is an array, the value of the parameter reference is the + length of the array. If the value 'length' is encountered in other contexts, normal + evaluation rules apply. 4. It is an error if the key does not match the required type, or the key is not found or out of range. 8. Repeat steps 3-8 diff --git a/conformance_tests.yaml b/conformance_tests.yaml index 465e56d6..753ae33a 100644 --- a/conformance_tests.yaml +++ b/conformance_tests.yaml @@ -3412,3 +3412,12 @@ doc: Test paramer reference that refers to length of non-array input should_fail: true tags: [ command_line_tool ] + +- job: tests/length_non_array_input.yml + tool: tests/params_input_length_non_array.cwl + doc: Test 'length' in parameter reference where it does not refer to length of an array input + tags: [ command_line_tool ] + output: + output1: 1 + output2: 2 + output3: 3 diff --git a/tests/length_non_array_input.yml b/tests/length_non_array_input.yml new file mode 100644 index 00000000..1caffb3e --- /dev/null +++ b/tests/length_non_array_input.yml @@ -0,0 +1,5 @@ +bar: + length: 2 +baz: + length: + bap: 3 \ No newline at end of file diff --git a/tests/params_input_length_non_array.cwl b/tests/params_input_length_non_array.cwl new file mode 100644 index 00000000..bbe50849 --- /dev/null +++ b/tests/params_input_length_non_array.cwl @@ -0,0 +1,40 @@ +class: CommandLineTool +cwlVersion: v1.2 +inputs: + length: + type: int + default: 1 + bar: + type: + type: record + name: bar_record + fields: + length: + type: int + baz: + type: + type: record + name: baz_record + fields: + length: + type: + type: record + name: length_record + fields: + bap: + type: int + +outputs: + output1: + type: int + outputBinding: + outputEval: $(inputs.length) + output2: + type: int + outputBinding: + outputEval: $(inputs.bar.length) + output3: + type: int + outputBinding: + outputEval: $(inputs.baz.length.bap) +baseCommand: "true" \ No newline at end of file From 871afac1c7373b37d223a4aed80869b461c8ed6f Mon Sep 17 00:00:00 2001 From: Peter van Heusden Date: Wed, 25 Nov 2020 22:50:24 +0200 Subject: [PATCH 5/5] Add required tag to new tests --- conformance_tests.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conformance_tests.yaml b/conformance_tests.yaml index 753ae33a..81675aa7 100644 --- a/conformance_tests.yaml +++ b/conformance_tests.yaml @@ -3405,18 +3405,18 @@ label: params_broken_null doc: Test parameter reference that refers to null.something should_fail: true - tags: [ command_line_tool ] + tags: [ required, command_line_tool ] - job: tests/empty.json tool: tests/params_broken_length_of_non_list.cwl doc: Test paramer reference that refers to length of non-array input should_fail: true - tags: [ command_line_tool ] + tags: [ required, command_line_tool ] - job: tests/length_non_array_input.yml tool: tests/params_input_length_non_array.cwl doc: Test 'length' in parameter reference where it does not refer to length of an array input - tags: [ command_line_tool ] + tags: [ required, command_line_tool ] output: output1: 1 output2: 2