Skip to content

feat(FOUR-34469): require version_name on deploy upsert updates - #9181

Open
gproly wants to merge 6 commits into
feature/FOUR-34328from
FOUR-34469
Open

gproly wants to merge 6 commits into
feature/FOUR-34328from
FOUR-34469

Conversation

@gproly

@gproly gproly commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Record deploy updates in package-versions VersionHistory (subject), matching the UI publish flow. Apply to deploy-screen, deploy-script, and deploy-process when the asset already exists.

https://processmaker.atlassian.net/browse/FOUR-34469

Record deploy updates in package-versions VersionHistory (subject),
matching the UI publish flow. Apply to deploy-screen, deploy-script,
and deploy-process when the asset already exists.

https://processmaker.atlassian.net/browse/FOUR-34469
@cursor

cursor Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes deploy upsert contracts (breaking for update callers without version_name) and depend on package-versions and automatic version publishing after save.

Overview
Deploy APIs for process, screen, and script now treat an existing asset name/title as an update and require version_name (optional version_description). Updates are rejected with 422 when package-versions is missing (version_history), so version history can always be recorded.

A shared DeployVersionName service and AppliesDeployVersionName trait centralize validation, pre-save published-version tracking, and post-save VersionHistory rows tied to the newly published version—aligned with UI publish behavior. Feature tests cover validation and persistence when package-versions is installed.

Reviewed by Cursor Bugbot for commit 76546bf. 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 1 potential issue.

Fix All in Cursor

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

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 76fe727. Configure here.

@cursor
cursor Bot requested a review from caleeli November 18, 2026 20:36

private function resolvePublishedVersionAfterSave(Model $asset, int $publishedVersionIdBefore): ?Model
{
$version = $asset->versions()->published()->orderByDesc('id')->first();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Agentic Security Review

Severity: MEDIUM

Description: Deploy version history is bound to the newest published version id after save, not to the version row this request inserted. On deploy-screen and deploy-script that lookup is outside a transaction, so a concurrent update of the same screen or script can commit a higher version id that this request then records as its own publish. The history row stores this caller's user id, version_name, and version_description on that other version. Export reads the first VersionHistory row for the latest version as last_modified_by, so the published screen or script can be attributed to the other deployer.

Impact: Two authenticated API users who can call deploy-screen or deploy-script (auth:api only; these routes have no asset permission middleware) can interleave updates of the same title. The slower resolver stamps the newer version row with the slower caller's identity and version label. That crosses the request-to-version authorship boundary: exporter manifests then report the wrong user as last_modified_by for the latest published screen or script. Executable screen config and script code are unchanged; the damage is cross-user publisher attribution and version-label integrity. The deploy-process path keeps the snapshot, save, and history insert in one transaction on the default MySQL InnoDB connection, so it does not observe the other deploy's committed version under REPEATABLE READ.

Remediation: Pass the version model returned by this request's saveVersion/saved hook into the history insert and set versionable_id to that id only. Do not re-select the latest published id. Keep screen and script snapshot, save, and history insert on that same version id so a newer concurrent row cannot match.

@decisions-sonarqube

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant