Skip to content

[Fix #1625] Add null check for required 'in' property in ForExecutorBuilder - #1626

Open
mcruzdev wants to merge 1 commit into
open-workflow-specification:mainfrom
mcruzdev:issue-1625
Open

[Fix #1625] Add null check for required 'in' property in ForExecutorBuilder#1626
mcruzdev wants to merge 1 commit into
open-workflow-specification:mainfrom
mcruzdev:issue-1625

Conversation

@mcruzdev

@mcruzdev mcruzdev commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

ForExecutorBuilder.buildCollectionFilter() dereferences task.getFor().getIn() without a null check. Programmatically-built workflows bypass schema validation, so a ForTask without 'in' set causes a raw NullPointerException with no context.

Added Objects.requireNonNull with a descriptive message and a test that verifies the error when 'in' is missing.

Closes #1625

@mcruzdev
mcruzdev requested a review from fjtirado as a code owner August 14, 2026 00:26
Copilot AI lite review requested due to automatic review settings August 14, 2026 00:26
…n' property in ForExecutorBuilder

ForExecutorBuilder.buildCollectionFilter() dereferences task.getFor().getIn()
without a null check. Programmatically-built workflows bypass schema validation,
so a ForTask without 'in' set causes a raw NullPointerException with no context.

Added Objects.requireNonNull with a descriptive message and a test that verifies
the error when 'in' is missing.

Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves validation/diagnostics for programmatically-built workflows by ensuring a missing required for.in value in a ForTask fails fast with a descriptive message (instead of a contextless NullPointerException), and adds a regression test for that behavior.

Changes:

  • Add Objects.requireNonNull(...) around task.getFor().getIn() in ForExecutorBuilder.buildCollectionFilter() with a clear error message.
  • Add a JUnit test that builds a ForTask without in and asserts the thrown exception includes the descriptive message.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
impl/core/src/main/java/io/serverlessworkflow/impl/executors/ForExecutor.java Adds a null check for required for.in and throws an NPE with a descriptive message.
impl/test/src/test/java/io/serverlessworkflow/impl/test/ForTaskMissingInTest.java Adds regression coverage ensuring missing in fails with a helpful message.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings August 14, 2026 00:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Suppressed comments (1)

impl/core/src/main/java/io/serverlessworkflow/impl/executors/ForExecutor.java:56

  • buildCollectionFilter() still dereferences task.getFor() without a null check. The schema requires for (in addition to for.in), and programmatic workflows can bypass schema validation, so a missing for will still throw a contextless NPE. Consider validating task.getFor() explicitly before accessing .getIn() so missing for fails with a descriptive message too.
    protected WorkflowValueResolver<Collection<?>> buildCollectionFilter() {
      In in =
          Objects.requireNonNull(task.getFor().getIn(), "'in' is a required property for ForTask");

@mcruzdev

Copy link
Copy Markdown
Collaborator Author

cc: @ricardozanini, it is important for 1.0.0

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.

ForExecutorBuilder missing null check on for.in (required field)

3 participants