[NAE-2419] Tasks with auto triggers fail to execute if they contain an assign event PRE action#438
[NAE-2419] Tasks with auto triggers fail to execute if they contain an assign event PRE action#438renczesstefan wants to merge 1 commit intorelease/7.0.0-rev10from
Conversation
…n assign event PRE action - added task updating using assignTaskEventOutcom
WalkthroughThe ChangesTask Assignment Outcome Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java (1)
617-627:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winGuard against a null
getTask()that would produce a secondary NPE inside thecatchblock.
assignTaskEventOutcome.getTask()is non-null under all currently reachable paths inassignTask(either the original task or the result offindOne, which throws rather than returns null). However, if a future change breaks that invariant, line 617 setstask = null, the very next line (task.getTitle()) throws aNullPointerException, thecatch (Exception e)on line 626 catches it, and thentask.getTitle()on line 627 throws a second NPE that escapesexecuteTransitionentirely — replacing the original exception and preventing the error from being logged.🛡️ Proposed defensive fix
- task = assignTaskEventOutcome.getTask(); + Task assignedTask = assignTaskEventOutcome.getTask(); + if (assignedTask == null) { + throw new IllegalStateException("assignTask returned a null task for transition [" + task.getTransitionId() + "]"); + } + task = assignedTask;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java` around lines 617 - 627, assignTaskEventOutcome.getTask() may be null and using task.getTitle() both inside the try and again in the catch can cause a secondary NPE that hides the original error; fix by capturing a null-safe task title immediately after obtaining the task (e.g. compute a local String taskTitle = task != null ? task.getTitle() : "<unknown>") and use that variable for the later log.info calls and in the catch log, or alternatively guard uses of task with null checks and log a placeholder when task is null; update references to assignTaskEventOutcome.getTask(), the local variable task, and any uses of getTitle() in this block accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java`:
- Around line 617-627: assignTaskEventOutcome.getTask() may be null and using
task.getTitle() both inside the try and again in the catch can cause a secondary
NPE that hides the original error; fix by capturing a null-safe task title
immediately after obtaining the task (e.g. compute a local String taskTitle =
task != null ? task.getTitle() : "<unknown>") and use that variable for the
later log.info calls and in the catch log, or alternatively guard uses of task
with null checks and log a placeholder when task is null; update references to
assignTaskEventOutcome.getTask(), the local variable task, and any uses of
getTitle() in this block accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 495dc490-0471-4a64-801d-055fdd6a7b86
📒 Files selected for processing (1)
application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java
Description
Implements NAE-2419
Dependencies
No new dependencies were introduced
Third party dependencies
No new dependencies were introduced
Blocking Pull requests
There are no dependencies on other PR
How Has Been This Tested?
This was tested manually and with unit tests.
Test Configuration
Checklist:
Summary by CodeRabbit