Skip to content

[NAE-2419] Tasks with auto triggers fail to execute if they contain an assign event PRE action#438

Open
renczesstefan wants to merge 1 commit intorelease/7.0.0-rev10from
NAE-2419
Open

[NAE-2419] Tasks with auto triggers fail to execute if they contain an assign event PRE action#438
renczesstefan wants to merge 1 commit intorelease/7.0.0-rev10from
NAE-2419

Conversation

@renczesstefan
Copy link
Copy Markdown
Member

@renczesstefan renczesstefan commented May 4, 2026

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

Name Tested on
OS macOS Tahoe 26.3
Runtime Java 21
Dependency Manager Maven 3.9.9n
Framework version Spring Boot 3.4.4
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @Retoocs
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • Bug Fixes
    • Improved task assignment to ensure proper state updates are captured during workflow transitions.

…n assign event PRE action

- added task updating using assignTaskEventOutcom
@renczesstefan renczesstefan self-assigned this May 4, 2026
@renczesstefan renczesstefan added the bugfix A change that fixes a bug label May 4, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Walkthrough

The executeTransition method in TaskService now captures the result of assignTask(...) as an AssignTaskEventOutcome and updates the local task reference from that outcome before proceeding to data retrieval and task completion.

Changes

Task Assignment Outcome Handling

Layer / File(s) Summary
Core Logic Update
application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java
assignTask(...) return value is now captured in AssignTaskEventOutcome; local task variable is updated from assignTaskEventOutcome.getTask() before continuing with data retrieval and task completion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

Medium

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the bug fix (NAE-2419) and clearly describes the specific issue: tasks with auto triggers failing when they contain assign event PRE actions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot added the Medium label May 4, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 win

Guard against a null getTask() that would produce a secondary NPE inside the catch block.

assignTaskEventOutcome.getTask() is non-null under all currently reachable paths in assignTask (either the original task or the result of findOne, which throws rather than returns null). However, if a future change breaks that invariant, line 617 sets task = null, the very next line (task.getTitle()) throws a NullPointerException, the catch (Exception e) on line 626 catches it, and then task.getTitle() on line 627 throws a second NPE that escapes executeTransition entirely — 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

📥 Commits

Reviewing files that changed from the base of the PR and between c627375 and a1ec52f.

📒 Files selected for processing (1)
  • application-engine/src/main/java/com/netgrif/application/engine/workflow/service/TaskService.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix A change that fixes a bug Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants