Skip to content

Fix "No such variable" in typed output block with job arrays#7221

Merged
bentsherman merged 3 commits into
masterfrom
fix-7215-array-typed-output
Jun 11, 2026
Merged

Fix "No such variable" in typed output block with job arrays#7221
bentsherman merged 3 commits into
masterfrom
fix-7215-array-typed-output

Conversation

@jorgee

@jorgee jorgee commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #7215.

A typed (v2) process that references an input variable in an output file pattern fails with ERROR ~ No such variable: <input> when job array batching is active, e.g.:

nextflow.enable.types = true

process getSce {
    input:
    localFile: Path

    output:
    sce: Path = file("${localFile.baseName}_sce.rds")

    script:
    """
    touch ${localFile.baseName}_sce.rds
    """
}
  • ✗ Fails: -profile slurm --arraySize 2 (array enabled)
  • ✓ Works: -profile slurm --arraySize 1 (no array)
  • ✓ Works: -profile local

Root cause

When array > 1, TaskArrayCollector.createTaskArray() builds a parent TaskArrayRun with a fresh, empty task context — it is only a launcher that dispatches the child tasks and stages no outputs of its own.

TaskBean calls getOutputFilesNames() for every task, including the array parent. For typed (v2) processes, getOutputFilesNamesV2() evaluates the process-level declared output patterns against the task context. The parent's context has no inputs bound, so resolving file("${localFile.baseName}_sce.rds") throws No such variable: localFile.

DSL v1 was unaffected because getOutputFilesNamesV1() reads the task's instance-resolved outputs, which are empty for the parent.

Fix

Override getOutputFilesNames() in TaskArrayRun to return an empty list. The array parent stages no outputs of its own (children unstage their own outputs); this matches the effective v1 behaviour and avoids evaluating output declarations against the parent's empty context.

Testing

  • New regression test in TaskArrayRunTest — verified it fails without the fix and passes with it.
  • Reproduced the original issue end-to-end on a local SLURM (docker) cluster and confirmed all three scenarios (slurm arraySize=2, slurm arraySize=1, local) now succeed, with child output files correctly produced and staged.

🤖 Generated with Claude Code

When job array batching is enabled (process `array` directive), the
parent `TaskArrayRun` is created with a fresh, empty task context — it is
only a launcher that dispatches its child tasks and stages no outputs of
its own.

However `TaskBean` calls `getOutputFilesNames()` for every task, including
the array parent. For typed (v2) processes this evaluates the
process-level declared output patterns against the task context, and a
pattern that references an input variable (e.g.
`file("${localFile.baseName}_sce.rds")`) fails with
`No such variable: localFile` because the parent context has no inputs
bound. DSL v1 was unaffected because it reads the task's instance-resolved
outputs, which are empty for the parent.

Override `getOutputFilesNames()` in `TaskArrayRun` to return an empty list,
matching the effective v1 behaviour and avoiding evaluation of output
declarations against the parent's empty context.

Fixes #7215

Signed-off-by: Jorge Ejarque <jorge.ejarque@seqera.io>
Signed-off-by: jorgee <jorge.ejarque@seqera.io>
@netlify

netlify Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 48222de
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/6a2adedb5d6d98000879cdb2

@jorgee jorgee requested a review from bentsherman June 11, 2026 09:22
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
@bentsherman bentsherman merged commit 064404b into master Jun 11, 2026
25 checks passed
@bentsherman bentsherman deleted the fix-7215-array-typed-output branch June 11, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No such variable error in typed output block when using array directive _

2 participants