Access to undefined parameter after refactor for vscode extension

Hi-
My pipeline is similar to this one. After refactoring it to appease the vscode extension, I’m getting errors like

Access to undefined parameter `fasta` -- Initialise it to a default value eg. `params.fasta = some_value`

even though that parameter is defined here.

The error is coming from this line, which is now inside the workflow definition due to the “Statements cannot be mixed with script declarations” error.

I have so far been unable to create an MWE. Has anyone seen this before?

I was able to create an MWE:

main.nf

#!/usr/bin/env nextflow

include {SUBWORKFLOW} from './subworkflow'

nextflow.enable.strict = true

params.test = "fake"

workflow {
         println("${params.test}")
         SUBWORKFLOW()
}

subworkflow.nf

workflow SUBWORKFLOW {
         println("${params.test}")
}

result

$ nextflow run .
Nextflow 24.10.3 is available - Please consider updating your version to it

 N E X T F L O W   ~  version 24.10.2

Launching `./main.nf` [evil_swartz] DSL2 - revision: 9dace5bcde

fake
Access to undefined parameter `test` -- Initialise it to a default value eg. `params.test = some_value` -- Check script './subworkflow.nf' at line: 2 or see '.nextflow.log' file for more details

Ah, the issue is that the vscode extension auto-formatting moves the import above the param definitions.

This seems like a bug with the formatter

Good catch! Please open an issue about this on the VSCode GitHub repo.

In the mean time you can turn off auto-formatting.

I should add: whilst I agree that the auto-formatting thing is bug-like behaviour, longer term the intention is to not use params globally.

So a better fix for you would be to pass the param as a take when you call the subworkflow instead.

Yeah, i was able to get around it by just saving that file specifically without formatting. thanks!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.