Stop issue move and clone when the update is invalid
What does this MR do and why?
Stops a move or clone from running when the issue update fails, and still reports the move or clone errors.
Issues::UpdateService#move_issue_to_new_container and #clone_issue call update(issue) and then run the data-sync service whatever the result. For a plain Issue, the data-sync service reloads the record from the database. Pending edits are lost and the stored version is moved or cloned. So a blank title, or a type change the issue does not allow, plus /move or /clone silently moved or cloned the issue and closed the source. A WorkItem was not affected, because the service validates the same dirty instance.
Changes:
WorkItems::DataSync::BaseService#verification_error(new, public, memoized) runs the existing permission, organization and target type checks without performing the action.executecalls it, so the checks live in one place.- When the update fails,
Issues::UpdateServicebuilds the move or clone service, collects itsverification_errorinto the deferred errors from !255660 (merged), and returns without callingexecute. The caller gets the update error and any move or clone error, each once. - "Update failed" means the save added errors. A deferred error such as the
/create_merge_requestrate limit no longer counts, so it does not block a valid move.
No feature flag. This is a bug fix.
References
- Part of the split of !260607 (merged).
- No dependencies. Based on
master. Not a prerequisite for !261249. - Builds on the error aggregation added in !255660 (merged).
How to set up and validate locally
- On a legacy issue page, add a note with
/move <other project>and/titlecleared, or send an issue update withtarget_containerand a blank title. - The response has the validation error. No issue is created in the target project and the source stays open.
- Repeat with
/clone. - Use
/create_merge_requestplus/movewhile the merge request rate limit is hit. The issue still moves.
Specs:
spec/services/issues/update_service_spec.rbspec/services/work_items/data_sync/move_service_spec.rbspec/services/work_items/data_sync/clone_service_spec.rb
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist.
Generated with Claude Code