nextflow-io / nextflow

A DSL for data-driven computational pipelines
http://nextflow.io
Apache License 2.0
2.77k stars 629 forks source link

two input variables with identical names are allowed #3874

Open jgbaum opened 1 year ago

jgbaum commented 1 year ago

Bug report

Nextflow seems to allow multiple input variables with identical names in the same process, which could lead to unexpected behavior.

Expected behavior and actual behavior

Nextflow should throw an error if a process contains multiple input variables with the same name.

Steps to reproduce the problem

Run the workflow below, which contains two input variables with the name 'sample_id'. This was originally taken from example 6.3.5 of the training documentation.

reads_ch = Channel.fromFilePairs('data/ggal/*_{1,2}.fq')

process FOO {
    input:
    tuple val(sample_id), path(sample_id)

    output:
    tuple val(sample_id), path('sample.bam')

    script:
    """
    echo your_command_here --reads $sample_id > sample.bam
    """
}

workflow {
    bam_ch = FOO(reads_ch)
    bam_ch.view()
}

Program output

N E X T F L O W  ~  version 22.10.7
Launching `processes.nf` [insane_goldstine] DSL2 - revision: 11430b8ce3
executor >  local (3)
[25/dbc431] process > FOO (2) [100%] 3 of 3 ✔
[[lung_1.fq, lung_2.fq], /Users/jgbaum/odrive/GDrive_LJI/_current_work/nextflow-training/random-scripts/work/b2/d2f9a3991d8f08d840546d2d80469c/sample.bam]
[[liver_1.fq, liver_2.fq], /Users/jgbaum/odrive/GDrive_LJI/_current_work/nextflow-training/random-scripts/work/c6/4905e0a1adf807ff156fc0dfff6d16/sample.bam]
[[gut_1.fq, gut_2.fq], /Users/jgbaum/odrive/GDrive_LJI/_current_work/nextflow-training/random-scripts/work/25/dbc4314edaca84665b1a89d57f4caa/sample.bam]

Environment

Additional context

This was originally raised in the nextflow training repo: https://github.com/nextflow-io/training/issues/231

adrajago commented 7 months ago

can I take this issue?

bentsherman commented 7 months ago

I think I made a PR for this already: #4376

Think it got stalled over concern that it would break existing pipelines, but seems like something that should break your pipeline

Maybe we could be more lenient and have it log a warning instead

adrajago commented 7 months ago

so have it send a warning to the user when inputting information?