viash-io / viash

script + metadata = standalone component
https://viash.io
GNU General Public License v3.0
39 stars 2 forks source link

nxf: nextflow platform doesn't escape descriptions and others #75

Closed rcannood closed 3 years ago

rcannood commented 3 years ago

The NextFlowPlatform doesn't escape everything it should.

Example component src/foo/config.vsh.yaml:

functionality:
  name: foo
  arguments: 
    - name: "--input"
      type: file
      required: true
    - name: "--output"
      type: file
      direction: output
      description: |
        here are some characters you might see in a description:
        $§1234567890''^°+"*ç%&/()=?`\
      required: true
  resources:
    - type: r_script
      dest: script.R
      text: |
        print(par)
        readr::write_rds(par, par$output)
platforms:
  - type: docker
    image: rocker/tidyverse:4.0.5
  - type: nextflow

Execution log:

$ viash ns build --setup cb
...
$ NXF_VER=21.04.1 nextflow run target/nextflow/src/main.nf --input src --output out.rds
N E X T F L O W  ~  version 21.04.1
Launching `target/nextflow/src/main.nf` [tender_kare] - revision: 3675b40efc
Unable to parse config file: 'target/nextflow/src/nextflow.config'

  Compile failed for sources FixedSetSources[name='/groovy/script/Script6F0CF58C0BCB663ED15F6F34A01D4CDE/_nf_config_931fbc31']. Cause: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
  /groovy/script/Script6F0CF58C0BCB663ED15F6F34A01D4CDE/_nf_config_931fbc31: 4: Unexpected input: '{' @ line 4, column 10.
       params {
              ^

  1 error

This is what the generated nextflow.config looks like:

        output {
          name = "output"
          otype = "--"
          required = true
          type = "file"
          direction = "Output"
          multiple = false
          multiple_sep = ":"
          value = "${params.foo__output}"
          description = "here are some characters you might see in a description:
$§1234567890''^°+"*ç%&/()=?`\
"
        }

This should have been escaped to be:

        output {
          name = "output"
          otype = "--"
          required = true
          type = "file"
          direction = "Output"
          multiple = false
          multiple_sep = ":"
          value = "${params.foo__output}"
          description = "here are some characters you might see in a description:\n\$§1234567890''^°+\"*ç%&/()=?`\\\n"
        }

Commit 4adcf25cb139699309d816d6f06c694dd75b8cc7 extends the nxf test to include some of these special characters to see if the pipeline can still run.

rcannood commented 3 years ago

Fixed in bbe82bd