Assigining an existing assignee with quick actions reports an Error 500
After I finished up a review, I was writing a note in the MR to unassign myself and assign the MR author.
Text:
/assign @seanarnold
/unassign me
The error was Your comment could not be submitted! Please check your network connection and try again.
If I click "Preview", I get the expected result (ie. the markdown is valid)
Request info in the inspector (with some stuff snipped)
Request URL: https://gitlab.com/gitlab-org/gitlab/notes?target_id=45165494&target_type=merge_request
Request Method: POST
Status Code: 500 Internal Server Error
Referrer Policy: origin-when-cross-origin
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Length: 2926
Content-Type: text/html; charset=utf-8
Date: Thu, 09 Jan 2020 07:19:04 GMT
GitLab-LB: fe-01-lb-gprd
GitLab-SV: web-cny-04-sv-gprd
Pragma: no-cache
Server: nginx
X-Request-Id: 3LCzMlyqZJ6
X-Runtime: 0.430595
Accept: application/json, text/plain, */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Connection: keep-alive
Content-Length: 181
Content-Type: application/json;charset=UTF-8
Host: gitlab.com
Origin: https://gitlab.com
Referer: https://gitlab.com/gitlab-org/gitlab/merge_requests/21802
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
X-Requested-With: XMLHttpRequest
Query String Parameters:
target_id: 45165494
target_type: merge_request
Request Payload:
note: {noteable_type: "MergeRequest", noteable_id: 45165494, note: "/assign @seanarnold ↵/unassign me"}
noteable_type: "MergeRequest"
noteable_id: 45165494
note: "/assign @seanarnold ↵/unassign me"
merge_request_diff_head_sha: "b220b6f77cc7f185dd7800857a155900740db10c"
Sentry error: https://sentry.gitlab.net/gitlab/gitlabcom/issues/1156700
Solution
If the merge request assignee already exists, don't attempt to assign again in a quick action.
Possible fix:
diff --git a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
index 183191f31a6..e26e0a3d668 100644
--- a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
+++ b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb
@@ -30,7 +30,7 @@ module Gitlab
if quick_action_target.allows_multiple_assignees?
@updates[:assignee_ids] ||= quick_action_target.assignees.map(&:id)
- @updates[:assignee_ids] += users.map(&:id)
+ @updates[:assignee_ids] |= users.map(&:id)
else
@updates[:assignee_ids] = [users.first.id]
end
Edited by Heinrich Lee Yu