Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {ChangedFieldsService} from '../../changed-fields/services/changed-fields
import {EventService} from '../../event/services/event.service';
import {ChangedFieldsMap} from '../../event/services/interfaces/changed-fields-map';
import {TaskEventOutcome} from '../../event/model/event-outcomes/task-outcomes/task-event-outcome';
import {FrontActionService} from '../../actions/services/front-action.service';
import {FrontAction} from '../../data-fields/models/changed-fields';


/**
Expand All @@ -41,6 +43,7 @@ export class AssignTaskService extends TaskHandlingService {
protected _taskDataService: TaskDataService,
protected _eventQueue: EventQueueService,
protected _eventService: EventService,
protected _frontActionService: FrontActionService,
protected _changedFieldsService: ChangedFieldsService,
@Inject(NAE_TASK_OPERATIONS) protected _taskOperations: TaskOperations,
@Optional() _selectedCaseService: SelectedCaseService,
Expand Down Expand Up @@ -124,6 +127,10 @@ export class AssignTaskService extends TaskHandlingService {
if (!!changedFieldsMap) {
this._changedFieldsService.emitChangedFields(changedFieldsMap);
}
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as AssignTaskEventOutcome);
Comment on lines +130 to 135

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Guard front-action execution so success flow cannot be aborted.

On Line 132, runAll() is not isolated; if any front action throws (including unknown action-id dispatch), the code after it won’t run (reload/forceReload, completeActions, snackbar), breaking event progression despite a successful backend response.

Proposed fix
 const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
 if (frontActions?.length > 0) {
-    this._frontActionService.runAll(frontActions);
+    try {
+        this._frontActionService.runAll(frontActions);
+    } catch (e) {
+        this._log.error('Executing front actions after assign failed', e);
+    }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as AssignTaskEventOutcome);
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
try {
this._frontActionService.runAll(frontActions);
} catch (e) {
this._log.error('Executing front actions after assign failed', e);
}
}
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as AssignTaskEventOutcome);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/netgrif-components-core/src/lib/task/services/assign-task.service.ts`
around lines 130 - 135, The _frontActionService.runAll(frontActions) call is not
isolated from the success flow and can abort execution if any front action
throws an error, preventing the subsequent reload/forceReload and
completeActions from running. Wrap the runAll() call in a try-catch block to
ensure that even if front action execution fails, the task operations
(forceReload or reload) and the completeActions method still execute to maintain
the proper event progression after a successful backend response.

this._snackBar.openSuccessSnackBar(!!outcomeResource.outcome.message
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {ChangedFieldsService} from '../../changed-fields/services/changed-fields
import { EventService} from '../../event/services/event.service';
import {ChangedFieldsMap} from '../../event/services/interfaces/changed-fields-map';
import {TaskEventOutcome} from '../../event/model/event-outcomes/task-outcomes/task-event-outcome';
import {FrontActionService} from "../../actions/services/front-action.service";
import {FrontAction} from "../../data-fields/models/changed-fields";

/**
* Service that handles the logic of canceling a task.
Expand All @@ -45,6 +47,7 @@ export class CancelTaskService extends TaskHandlingService {
protected _eventQueue: EventQueueService,
protected _eventService: EventService,
protected _changedFieldsService: ChangedFieldsService,
protected _frontActionService: FrontActionService,
@Inject(NAE_TASK_OPERATIONS) protected _taskOperations: TaskOperations,
@Optional() _selectedCaseService: SelectedCaseService,
@Optional() protected _taskViewService: TaskViewService,
Expand Down Expand Up @@ -126,6 +129,10 @@ export class CancelTaskService extends TaskHandlingService {
if (!!changedFieldsMap) {
this._changedFieldsService.emitChangedFields(changedFieldsMap);
}
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as CancelTaskEventOutcome);
Comment on lines +132 to 137

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Protect cancel success path from front-action runtime failures.

On Line 134, a thrown front action can interrupt the success branch before reload and completeActions, leaving cancel lifecycle callbacks unresolved.

Proposed fix
 const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
 if (frontActions?.length > 0) {
-    this._frontActionService.runAll(frontActions);
+    try {
+        this._frontActionService.runAll(frontActions);
+    } catch (e) {
+        this._log.error('Executing front actions after cancel failed', e);
+    }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as CancelTaskEventOutcome);
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
try {
this._frontActionService.runAll(frontActions);
} catch (e) {
this._log.error('Executing front actions after cancel failed', e);
}
}
forceReload ? this._taskOperations.forceReload() : this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as CancelTaskEventOutcome);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/netgrif-components-core/src/lib/task/services/cancel-task.service.ts`
around lines 132 - 137, The front action execution via
this._frontActionService.runAll(frontActions) can throw an error and prevent the
subsequent reload and completeActions from being called, leaving cancel
lifecycle callbacks unresolved. Wrap the front action execution in a try-catch
block to ensure that if a front action fails, the error is handled gracefully
and the reload (either forceReload or reload via this._taskOperations) and the
completeActions method with afterAction, nextEvent, and outcomeResource.outcome
are still executed to properly complete the cancel lifecycle.

} else if (outcomeResource.error !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import {ChangedFieldsService} from '../../changed-fields/services/changed-fields
import {EventService} from '../../event/services/event.service';
import {ChangedFieldsMap} from '../../event/services/interfaces/changed-fields-map';
import {TaskEventOutcome} from '../../event/model/event-outcomes/task-outcomes/task-event-outcome';
import {FrontActionService} from '../../actions/services/front-action.service';
import {FrontAction} from '../../data-fields/models/changed-fields';


/**
Expand All @@ -43,6 +45,7 @@ export class FinishTaskService extends TaskHandlingService {
protected _eventQueue: EventQueueService,
protected _eventService: EventService,
protected _changedFieldsService: ChangedFieldsService,
protected _frontActionService: FrontActionService,
@Inject(NAE_TASK_OPERATIONS) protected _taskOperations: TaskOperations,
@Optional() _selectedCaseService: SelectedCaseService,
_taskContentService: TaskContentService) {
Expand Down Expand Up @@ -140,6 +143,10 @@ export class FinishTaskService extends TaskHandlingService {
if (!!changedFieldsMap) {
this._changedFieldsService.emitChangedFields(changedFieldsMap);
}
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as FinishTaskEventOutcome);
this._taskOperations.close();
Comment on lines +146 to 152

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Isolate front-action failures in finish success handling.

On Line 148, uncaught exceptions from runAll() can prevent reload, completeActions, and close, causing a broken post-finish state after a successful backend finish.

Proposed fix
 const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
 if (frontActions?.length > 0) {
-    this._frontActionService.runAll(frontActions);
+    try {
+        this._frontActionService.runAll(frontActions);
+    } catch (e) {
+        this._log.error('Executing front actions after finish failed', e);
+    }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
this._frontActionService.runAll(frontActions);
}
this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as FinishTaskEventOutcome);
this._taskOperations.close();
const frontActions: Array<FrontAction> = this._eventService.parseFrontActionsFromOutcomeTree(outcomeResource.outcome);
if (frontActions?.length > 0) {
try {
this._frontActionService.runAll(frontActions);
} catch (e) {
this._log.error('Executing front actions after finish failed', e);
}
}
this._taskOperations.reload();
this.completeActions(afterAction, nextEvent, true, outcomeResource.outcome as FinishTaskEventOutcome);
this._taskOperations.close();
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@projects/netgrif-components-core/src/lib/task/services/finish-task.service.ts`
around lines 146 - 152, The _frontActionService.runAll(frontActions) call on
line 148 is not wrapped in error handling, which means any uncaught exceptions
from runAll will prevent the subsequent calls to _taskOperations.reload(),
completeActions(), and _taskOperations.close() from executing, leaving the
system in a broken post-finish state. Wrap the runAll() invocation in a
try-catch block to isolate front-action failures while ensuring that reload,
completeActions, and close operations continue to execute regardless of whether
runAll throws an exception.

Expand Down
Loading