Skip to content

Add null checks in TowerClient onFlowComplete method#6384

Merged
bentsherman merged 2 commits intomasterfrom
null-safe-thread-closing-nf-tower-plugin
Sep 5, 2025
Merged

Add null checks in TowerClient onFlowComplete method#6384
bentsherman merged 2 commits intomasterfrom
null-safe-thread-closing-nf-tower-plugin

Conversation

@robsyme
Copy link
Collaborator

@robsyme robsyme commented Sep 5, 2025

Fix NullPointerException in nf-tower plugin when onFlowBegin fails

Summary

Add defensive null checking for sender thread and workflowId to prevent NullPointerException when onFlowComplete is called after initialization failures in onFlowCreate or onFlowBegin methods.

  • Add null checks for sender thread and workflowId in TowerClient.onFlowComplete()
  • Prevents NullPointerException when Tower API rejects configuration with HTTP 400
  • Fixes workflow failure cascade caused by early exit from onFlowBegin hook

Problem

When Nextflow encounters invalid configuration (e.g., #6382 ), the following cascade occurs:

  1. Nextflow sends malformed configuration to Seqera Platform via onFlowBegin hook
  2. Platform rejects configuration and returns HTTP 400 response
  3. nf-tower plugin receives 400 response and throws AbortOperationException in onFlowBegin
  4. Early exit from onFlowBegin prevents initialization of sender thread and workflowId
  5. When workflow completes, onFlowComplete() calls sender.join() on null reference
  6. NullPointerException causes workflow to fail, masking the original configuration issue

This was reported in community forum thread and Seqera internal ticket #6701, where users experienced "Workflow execution completed unsuccessfully" despite successful pipeline runs, due to Tower communication failures caused by configuration parsing issues.

Solution

Added defensive null checks in onFlowComplete():

  • sender thread check: Skip thread join if sender was never initialized due to onFlowBegin failure
  • workflowId check: Skip completion HTTP request if workflow ID was never set due to onFlowCreate failure

These changes ensure that initialization failures don't cause secondary NullPointerExceptions that mask the root cause, allowing users to see the actual configuration errors.

Test Plan

  • Verify existing nf-tower plugin tests pass
  • Confirm project compilation succeeds
  • Test with malformed configuration to ensure graceful handling (not necessary)
  • Verify workflow completion reporting works correctly after configuration fixes (not necessary)

Related Issues

Add defensive null checking for sender thread and workflowId to prevent
NullPointerException when onFlowComplete is called after initialization
failures in onFlowCreate or onFlowBegin methods.

Signed-off-by: Rob Syme <rob.syme@gmail.com>
@netlify
Copy link

netlify bot commented Sep 5, 2025

Deploy Preview for nextflow-docs-staging canceled.

Name Link
🔨 Latest commit 619c8ef
🔍 Latest deploy log https://app.netlify.com/projects/nextflow-docs-staging/deploys/68bb55b577229e0008569e03

@bentsherman bentsherman self-requested a review September 5, 2025 20:46
Copy link
Member

@bentsherman bentsherman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to perform the remaining tests in your TODOs or is it ready to merge?

@robsyme
Copy link
Collaborator Author

robsyme commented Sep 5, 2025

I originally added some tests, but they were so contrived that I ended up removing them from the commit.
The PR is just adding defensiveness, so I think we're good to merge.

@bentsherman bentsherman merged commit de968f0 into master Sep 5, 2025
22 checks passed
@bentsherman bentsherman deleted the null-safe-thread-closing-nf-tower-plugin branch September 5, 2025 23:05
pditommaso pushed a commit that referenced this pull request Sep 8, 2025
Add defensive null checking for sender thread and workflowId to prevent NullPointerException when onFlowComplete is called after initialization failures in onFlowCreate or onFlowBegin methods.

Signed-off-by: Rob Syme <rob.syme@gmail.com>
Co-authored-by: Ben Sherman <bentshermann@gmail.com>
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.

3 participants