Repository: common-workflow-language/cwltool

Issue:
Bizarre javascript error when running CWL with no javascript
I am trying to run the cat-tool-shortcut conformance test that has been packed using `cwlpack --json --add-ids`:

```json
{
  "baseCommand": [
    "cat"
  ],
  "class": "CommandLineTool",
  "cwlVersion": "v1.2",
  "id": "cat-tool-shortcut.cwl",
  "inputs": [
    {
      "id": "file1",
      "type": "stdin"
    }
  ],
  "outputs": [
    {
      "id": "output",
      "outputBinding": {
        "glob": "output"
      },
      "type": "File"
    }
  ],
  "requirements": [
    {
      "class": "DockerRequirement",
      "dockerPull": "debian:stretch-slim"
    }
  ],
  "stdout": "output"
}
```

cwltool fails with the following error:

```
Syntax error in parameter reference '(inputs.cat-tool-shortcut.cwl/file1.path)'. This could be due to using Javascript code without specifying InlineJavascriptRequirement.
Traceback (most recent call last):
  File "/Users/jdidion/.pyenv/versions/3.8.11/envs/dxc/lib/python3.8/site-packages/cwltool/expression.py", line 393, in do_eval
    return interpolate(
  File "/Users/jdidion/.pyenv/versions/3.8.11/envs/dxc/lib/python3.8/site-packages/cwltool/expression.py", line 297, in interpolate
    e = evaluator(
  File "/Users/jdidion/.pyenv/versions/3.8.11/envs/dxc/lib/python3.8/site-packages/cwltool/expression.py", line 249, in evaluator
    raise JavascriptException(
cwltool.sandboxjs.JavascriptException: Syntax error in parameter reference '(inputs.cat-tool-shortcut.cwl/file1.path)'. This could be due to using Javascript code without specifying InlineJavascriptRequirement.
ERROR Input object failed validation:
test/cwl_conformance/tools/cat-tool-shortcut.cwl.json:1:1: Expression evaluation error:
                                                           Syntax error in parameter reference
                                                           '(inputs.cat-tool-shortcut.cwl/file1.path)'.
                                                           This could be due to using Javascript
                                                           code without specifying
                                                           InlineJavascriptRequirement.
```


Discussion:
I can confirm; and that this is due to the injected `id` field. Testing a fix now.

Resolving patch:
diff --git a/cwltool/load_tool.py b/cwltool/load_tool.py
--- a/cwltool/load_tool.py
+++ b/cwltool/load_tool.py
@@ -207,7 +207,7 @@ def _convert_stdstreams_to_files(
                     else:
                         workflowobj["stdin"] = (
                             "$(inputs.%s.path)"
-                            % cast(str, inp["id"]).rpartition("#")[2]
+                            % cast(str, inp["id"]).rpartition("#")[2].split("/")[-1]
                         )
                         inp["type"] = "File"
         else:


Test patch:
diff --git a/tests/test_examples.py b/tests/test_examples.py
--- a/tests/test_examples.py
+++ b/tests/test_examples.py
@@ -1303,6 +1303,18 @@ def test_bad_stdout_expr_error() -> None:
     )
 
 
+def test_stdin_with_id_preset() -> None:
+    """Confirm that a type: stdin with a preset id does not give an error."""
+    error_code, _, stderr = get_main_output(
+        [
+            get_data("tests/wf/1590.cwl"),
+            "--file1",
+            get_data("tests/wf/whale.txt"),
+        ]
+    )
+    assert error_code == 0
+
+
 @needs_docker
 @pytest.mark.parametrize("factor", test_factors)
 def test_no_compute_chcksum(tmp_path: Path, factor: str) -> None:
diff --git a/tests/wf/1590.cwl b/tests/wf/1590.cwl
new file mode 100644
--- /dev/null
+++ b/tests/wf/1590.cwl
@@ -0,0 +1,30 @@
+{
+  "baseCommand": [
+    "cat"
+  ],
+  "class": "CommandLineTool",
+  "cwlVersion": "v1.2",
+  "id": "cat-tool-shortcut.cwl",
+  "inputs": [
+    {
+      "id": "file1",
+      "type": "stdin"
+    }
+  ],
+  "outputs": [
+    {
+      "id": "output",
+      "outputBinding": {
+        "glob": "output"
+      },
+      "type": "File"
+    }
+  ],
+  "requirements": [
+    {
+      "class": "DockerRequirement",
+      "dockerPull": "debian:stretch-slim"
+    }
+  ],
+  "stdout": "output"
+}