Drop type change success message when update fails

What does this MR do and why?

Drops the success message from the quick action response when a /type, /promote_to or /promote_to_incident type change is rejected.

The bug is in the API payload, not the UI. When a note has /type or /promote_to and the update fails validation, the response still carries the success message next to the error. An example is /type Task on an issue that has a child task. The error says "Work item type cannot be changed to Task with these child item types.", and the message list says "Type changed successfully." anyway. Two API paths return both at once:

  • GraphQL createNote returns quickActionsStatus.messages: ["Type changed successfully."] together with errorMessages: ["Work item type cannot be changed to Task with these child item types."].
  • The legacy notes controller (app/controllers/concerns/notes_actions.rb:71) returns a 422 with quick_actions_status: { messages: [...], error_messages: [...] }, again both at once.

The UI does not show the contradiction. Since b3cf470a ("Suppress the quick action summary when commands error", 2026-07-29), work_item_add_note.vue drops messages whenever errors are present. The legacy notes UI (notes/utils.js) shows only error_messages on a 422. So commenting /type Task in the browser shows only the error. API clients that read messages still get both. REST /api/v4 notes are not affected, because they return only the error messages.

This is an API contract fix. The frontend workaround can stay, and removing it would be a separate follow-up.

When the failed update params contain work_item_type, this MR removes only the success strings of type, promote_to and promote_to_incident. All other messages stay. Error text stored under the same command stays too. For example, "Failed to convert this work item: Provided type is not supported." is kept.

/promote_to_incident has the same problem: "Issue has been promoted to incident" showed next to a rejected type change. The command no longer uses a static execution_message. It sets @execution_message[:promote_to_incident] from success_msg[:promote_to_incident], which is the generic "Promoted successfully." (the same string as /promote_to), so the same strip applies. Custom types based on Issue can run /promote_to_incident, and the old text named the Issue type. This is a visible change on the success path too.

Legacy /promote (issue to epic) is not covered here. On master its failure raises PromoteError out of Notes::CreateService instead of coming back as an update error, so there is no failed-update path to hook into. The PromoteError rescue only exists in !260607 (merged), so that MR carries the /promote fix.

Root cause and why the fix is narrow

Quick action messages are built while the commands are interpreted. lib/gitlab/quick_actions/work_item_actions.rb sets the type message at that point. Notes::CreateService#do_commands applies the update later. When that update was rejected, the service only added the error and left the message in place.

The fix adds QuickActions::InterpretService#remove_type_change_success_message, delegated through Notes::QuickActionsService. Notes::CreateService calls it when the failed update params include work_item_type.

An earlier draft cleared all messages on failure. That hid messages from commands that did apply, such as /close, /subscribe and /add_email. These persist before or outside the failing save, so their messages are still true. Hence only the type, promote_to and promote_to_incident success strings are removed. Removing only known success strings also keeps error text that is stored under the same command, such as the unsupported-type error from /type.

Out of scope: Notes::UpdateService ignores the apply_updates result when a note is edited to add commands. That gap is pre-existing and this MR does not touch it.

References

  • !260607 (merged) is stacked on this MR.
  • Related: !260607 (merged) (rejects disabled work item types on type change). With that flag on, /type Issue with Issue disabled showed the same contradictory message. This MR is based on master and must merge first.
  • Follow-up: !261247 (merged) builds on this MR to drop the legacy /promote success message when promotion fails. It needs !261244 (merged) merged first so /promote returns errors instead of a 500.

How to set up and validate locally

  1. Create an issue work item with a child task.
  2. Add a note with /type Task using the GraphQL createNote mutation, or inspect the network response. The UI hides messages when errors exist, so it cannot show the fix.
  3. Check quickActionsStatus. errorMessages has the child-type error, and messages no longer has "Type changed successfully.".
  4. On a new issue with a child task, add a note with /type Task and /close on separate lines. The issue is closed, the type is unchanged, and messages is ["Closed this item."] with the error still present.

Specs:

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