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. execute calls it, so the checks live in one place.
  • When the update fails, Issues::UpdateService builds the move or clone service, collects its verification_error into the deferred errors from !255660 (merged), and returns without calling execute. 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_request rate limit no longer counts, so it does not block a valid move.

No feature flag. This is a bug fix.

References

How to set up and validate locally

  1. On a legacy issue page, add a note with /move <other project> and /title cleared, or send an issue update with target_container and a blank title.
  2. The response has the validation error. No issue is created in the target project and the source stays open.
  3. Repeat with /clone.
  4. Use /create_merge_request plus /move while the merge request rate limit is hit. The issue still moves.

Specs:

  • spec/services/issues/update_service_spec.rb
  • spec/services/work_items/data_sync/move_service_spec.rb
  • spec/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

Edited by Alexandru Croitor

Merge request reports

Loading
Loading