fix: Exception on loop after agent call#1289
Open
matheusandre1 wants to merge 4 commits intoserverlessworkflow:mainfrom
Open
fix: Exception on loop after agent call#1289matheusandre1 wants to merge 4 commits intoserverlessworkflow:mainfrom
matheusandre1 wants to merge 4 commits intoserverlessworkflow:mainfrom
Conversation
Signed-off-by: Matheus Andre <matheusandr2@gmail> Signed-off-by: Matheus Andre <matheusandr2@gmail.com>
fjtirado
reviewed
Apr 6, 2026
...l/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java
Outdated
Show resolved
Hide resolved
fjtirado
approved these changes
Apr 6, 2026
…zation tests Signed-off-by: Matheus Andre <matheusandr2@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #824 by addressing a NullPointerException that occurred when looping after an agent call. The root cause was that ForTaskFunction.getForClass() and other Optional fields could return null, causing NPE when calling .isPresent() on them. The fix ensures all Optional fields are properly initialized and maintained as non-null throughout the object's lifecycle, including after serialization/deserialization.
Changes:
- Initialize Optional fields with
Optional.empty()as defaults and add defensive normalization in constructor and deserialization - Add
readObject()method to handle deserialization safely - Update
JavaForExecutorBuilderto use safer Optional patterns (.map().orElse()instead of.isPresent()) - Add comprehensive regression tests covering initialization, serialization, and execution scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| experimental/types/src/main/java/io/serverlessworkflow/api/types/func/ForTaskFunction.java | Added default initialization of Optional fields, constructor, normalization logic, and readObject method for deserialization |
| experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java | Updated collectionFilterObject method to use safer Optional pattern |
| experimental/lambda/src/test/java/io/serverless/workflow/impl/executors/func/ForTaskFunctionRegressionTest.java | New test file with regression tests for Optional field initialization, serialization, and for-loop execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
experimental/types/src/main/java/io/serverlessworkflow/api/types/func/ForTaskFunction.java
Outdated
Show resolved
Hide resolved
fjtirado
reviewed
Apr 7, 2026
...l/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaForExecutorBuilder.java
Outdated
Show resolved
Hide resolved
fjtirado
reviewed
Apr 7, 2026
experimental/types/src/main/java/io/serverlessworkflow/api/types/func/ForTaskFunction.java
Outdated
Show resolved
Hide resolved
fjtirado
reviewed
Apr 7, 2026
experimental/types/src/main/java/io/serverlessworkflow/api/types/func/ForTaskFunction.java
Show resolved
Hide resolved
fjtirado
reviewed
Apr 7, 2026
experimental/types/src/main/java/io/serverlessworkflow/api/types/func/ForTaskFunction.java
Outdated
Show resolved
Hide resolved
Collaborator
|
@matheusandre1 can you update the PR with my lastest comment in order to merge it? |
Signed-off-by: Matheus Andre <matheusandr2@gmail.com>
Signed-off-by: Matheus Andre <matheusandr2@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Many thanks for submitting your Pull Request ❤️!
What this PR does / why we need it: Fixes: #824
Special notes for reviewers: modified validations and I set it to optional.empty by default.
Additional information (if needed):