Skip to content

FOUR-32144: Improve the api PUT /api/1.0/tasks/{task-id} - #9045

Open
pmPaulis wants to merge 9 commits into
developfrom
task/FOUR-32144
Open

FOUR-32144: Improve the api PUT /api/1.0/tasks/{task-id}#9045
pmPaulis wants to merge 9 commits into
developfrom
task/FOUR-32144

Conversation

@pmPaulis

@pmPaulis pmPaulis commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Improve the api PUT /api/1.0/tasks/{task-id}

Related Tickets & Packages

Code Review Checklist

  • I have pulled this code locally and tested it on my instance, along with any associated packages.
  • This code adheres to ProcessMaker Coding Guidelines.
  • This code includes a unit test or an E2E test that tests its functionality, or is covered by an existing test.
  • This solution fixes the bug reported in the original ticket.
  • This solution does not alter the expected output of a component in a way that would break existing Processes.
  • This solution does not implement any breaking changes that would invalidate documentation or cause existing Processes to fail.
  • This solution has been tested with enterprise packages that rely on its functionality and does not introduce bugs in those packages.
  • This code does not duplicate functionality that already exists in the framework or in ProcessMaker.
  • This ticket conforms to the PRD associated with this part of ProcessMaker.

ci:deploy

@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Changes core BPMN task completion and persistence paths behind feature flags; misconfiguration or raw-SQL drift from Eloquent behavior could affect workflow data integrity and authorization.

Overview
Adds an opt-in fast path for completing tasks via PUT /api/1.1/tasks/{id} (flags TASK_UPDATE_V1_1_ENABLED / TOKEN_PERSISTENCE_RAW_ENABLED, both default off). The endpoint only accepts status: COMPLETED; other updates still go through API 1.0.

Completion uses raw SQL reads (TaskCompletionRawRepository), authorization on lightly hydrated models (TaskCompletionEngineBridge), sanitized payload data, then WorkflowManager::completeTask. When raw persistence is enabled, TokenRepository and ExecutionInstanceRepository write token and request instance changes through TokenPersistenceRawRepository instead of full Eloquent saves.

Indexed search: ProcessRequest and ProcessRequestToken gain wasSearchableBeforeUpdate / wasSearchableBeforeDelete so Scout does not queue RemoveFromSearch when indexed search is disabled.

Queue: GenerateUserRecommendations implements ShouldBeUnique per user (60s) to collapse duplicate dispatches from Smart Inbox / activity events.

Reviewed by Cursor Bugbot for commit daafb12. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 5 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5e7ca61. Configure here.

'completed_at',
'token_properties',
]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Raw save skips completion timestamp

High Severity

Raw token updates skip ProcessRequestTokenObserver, so completed_at_ms is never set. After persist, BpmnSubscriber calls diffInMilliseconds on that null value and task completion fails whenever token_persistence_raw_enabled is on.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e7ca61. Configure here.

if (array_key_exists($field, $instance->getDirty())) {
$payload[$field] = $instance->getAttributes()[$field];
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Raw persist drops signal events

High Severity

The raw persistInstanceUpdated path only writes status, last_stage_id, last_stage_name, progress, and completed_at. signal_events from updateCatchEvents never reaches the database, so signal and boundary catch events can miss incoming signals.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e7ca61. Configure here.


$this->runUpdate('process_requests', (int) $instance->getKey(), $payload);
$instance->syncChanges();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Raw persist skips case title

Medium Severity

Raw instance updates skip ProcessRequestObserver::saving, so case_title and case_title_formatted are not recomputed when request data changes. Inbox and case lists keep stale titles until a later Eloquent save.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e7ca61. Configure here.

'data',
'token_properties',
]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Raw save leaves scheduled tasks

High Severity

Closing or completing a token via raw SQL never runs ProcessRequestTokenObserver::saved, so timer scheduledTasks for that token are not deleted and can still fire after the activity is done.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e7ca61. Configure here.


$this->runUpdate('process_request_tokens', $tokenId, $payload);
$token->syncChanges();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Raw persist skips search indexing

Medium Severity

Raw SQL updates do not fire Scout saved hooks. When indexed search is enabled, ProcessRequest and ProcessRequestToken documents are not updated after completion, so search results go stale.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e7ca61. Configure here.

@nolanpro

nolanpro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://ci-eaf6871c59.engk8s.processmaker.net

@decisions-sonarqube

Copy link
Copy Markdown

@nolanpro

nolanpro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

QA server K8S was successfully deployed https://ci-eaf6871c59.engk8s.processmaker.net

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants