Skip to content

Fix: handle empty publishedValues in PublishOp.onComplete for optional outputs#6979

Merged
bentsherman merged 2 commits intomasterfrom
6978-module-run-crashes-with-cannot-access-first-element-from-an-empty-list-when-process-has-empty-optional-outputs
Mar 26, 2026
Merged

Fix: handle empty publishedValues in PublishOp.onComplete for optional outputs#6979
bentsherman merged 2 commits intomasterfrom
6978-module-run-crashes-with-cannot-access-first-element-from-an-empty-list-when-process-has-empty-optional-outputs

Conversation

@jorgee
Copy link
Contributor

@jorgee jorgee commented Mar 26, 2026

Summary

  • Fixes NoSuchElementException: Cannot access first() element from an empty List in PublishOp.onComplete when a process has optional output channels that produce no files
  • Guards the .first() call with an empty-list check, returning null when no values were published on a value channel

Fixes #6978

Test plan

  • Run nextflow module run on a module with optional outputs that produce no files (e.g. nf-core/trimgalore with parameters that skip optional outputs)
  • Verify the run completes successfully and publishes only the non-empty outputs
  • Verify existing publish behaviour is unchanged when optional outputs do produce files

🤖 Generated with Claude Code

Signed-off-by: jorgee <jorge.ejarque@seqera.io>
@netlify
Copy link

netlify bot commented Mar 26, 2026

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit fd6568e
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/69c523386bc3fd00087a9c60

@jorgee
Copy link
Contributor Author

jorgee commented Mar 26, 2026

Current implementation is printing the optional outputs with null. It is easy not to print them, but the print feature is the OutputDsl . It will also apply to workflows. Moreover, not sure if it could be better to print with nulls for completeness

Signed-off-by: Ben Sherman <bentshermann@gmail.com>
@bentsherman
Copy link
Member

Thanks Jorge. This issue has actually been reported in other places as well.

It comes from the fact that some operations can produce an empty dataflow value, which is invalid since a dataflow value should always contain a value (even if null).

Most of these cases are addressed by typed processes and typed workflows, and could be avoided in legacy code using ifEmpty.

In this case, we could add a post-processing step to ProcessEntryHandler to impute empty dataflow values with null, but we might as well just solve the issue for everyone

Printing null is intentional for optional outputs, to show that they exist but are optional

@bentsherman bentsherman merged commit a99fb5d into master Mar 26, 2026
23 checks passed
@bentsherman bentsherman deleted the 6978-module-run-crashes-with-cannot-access-first-element-from-an-empty-list-when-process-has-empty-optional-outputs branch March 26, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

3 participants