[Fix #1625] Add null check for required 'in' property in ForExecutorBuilder - #1626
[Fix #1625] Add null check for required 'in' property in ForExecutorBuilder#1626mcruzdev wants to merge 1 commit into
Conversation
…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>
There was a problem hiding this comment.
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(...)aroundtask.getFor().getIn()inForExecutorBuilder.buildCollectionFilter()with a clear error message. - Add a JUnit test that builds a
ForTaskwithoutinand 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.
There was a problem hiding this comment.
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 dereferencestask.getFor()without a null check. The schema requiresfor(in addition tofor.in), and programmatic workflows can bypass schema validation, so a missingforwill still throw a contextless NPE. Consider validatingtask.getFor()explicitly before accessing.getIn()so missingforfails with a descriptive message too.
protected WorkflowValueResolver<Collection<?>> buildCollectionFilter() {
In in =
Objects.requireNonNull(task.getFor().getIn(), "'in' is a required property for ForTask");
|
cc: @ricardozanini, it is important for 1.0.0 |
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