-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix(execution): prevent NPE in SetVariables when variables are null #13776
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix(execution): prevent NPE in SetVariables when variables are null #13776
Conversation
|
I wonder if the correct fix should not be to add flow variables to the execution when we trigger an execution from a Webhook. |
|
Thanks for the insight that makes sense 👍 My intention with this PR was to provide a minimal and defensive fix at the task level, since That said, I agree that initializing flow variables when creating the execution from a webhook could be a more correct and consistent fix, especially since other triggers already do this. If you think that’s the preferred approach, I’m happy to adjust the PR to initialize variables at execution creation time instead (or complement this fix accordingly). Let me know which direction you’d prefer. |
|
I'm OK to keep a defensive code in this place as it would prevent other source of bugs (a NPE is always a bug), but we should also fix missing flow variable for Webhook to align with other kind of triggers. |
|
I’ve added initialization of execution variables in the Webhook trigger using flow.getVariables(), aligning webhook executions with other triggers while keeping the defensive fix in SetVariables. Let me know if anything else should be adjusted. |
loicmathieu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also revert most of your code format change (line lenght) to keep only real changes in the PR as it will be easier to follow.
core/src/main/java/io/kestra/plugin/core/execution/SetVariables.java
Outdated
Show resolved
Hide resolved
|
Done 👍 |
✨ Description
This PR fixes a NullPointerException in the
SetVariablestask when execution variables are not initialized.When
overwrite: falseis used, the task assumedexecution.getVariables()was non-null and attempted to callcontainsKey(...), which caused a crash for webhook-triggered executions (and some manual executions).The fix defensively initializes a local variables map before performing duplicate checks and merges, preserving existing behavior while preventing the NPE.
🔗 Related Issue
Closes #13756
🛠️ Backend Checklist
📝 Additional Notes
The issue author mentioned that webhook-triggered executions may not initialize variables at creation time.
This fix makes
SetVariablesresilient to that case without changing execution semantics.