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
createNotereturnsquickActionsStatus.messages: ["Type changed successfully."]together witherrorMessages: ["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 withquick_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 Issuewith Issue disabled showed the same contradictory message. This MR is based onmasterand must merge first. - Follow-up: !261247 (merged) builds on this MR to drop the legacy
/promotesuccess message when promotion fails. It needs !261244 (merged) merged first so/promotereturns errors instead of a 500.
How to set up and validate locally
- Create an issue work item with a child task.
- Add a note with
/type Taskusing the GraphQLcreateNotemutation, or inspect the network response. The UI hidesmessageswhen errors exist, so it cannot show the fix. - Check
quickActionsStatus.errorMessageshas the child-type error, andmessagesno longer has "Type changed successfully.". - On a new issue with a child task, add a note with
/type Taskand/closeon separate lines. The issue is closed, the type is unchanged, andmessagesis["Closed this item."]with the error still present.
Specs:
/type Taskon an issue with a child task. Red before, green after./type Taskplus/close. Issue closed, type unchanged,messages == ["Closed this item."], error present./promote_to_incidentrejected on an issue whose parent is an epic (incident cannot be a child of an epic). Red before, green after. And the type error kept when/promote_to_incidentis also rejected (/type Nonexistentplus/promote_to_incident). The second keeps the unsupported-type error inmessages. EE spec./type Taskrejected by validation, with and without/close.remove_type_change_success_messageunit specs for/promote_to_incident,/type, and a type error that must stay. They also cover two commands sharing the same success message.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist.
Generated with Claude Code