Fix GitLab bot creating resolvable threads that prevent merging
Summary
This MR fixes issue gitlab-org/developer-relations/contributor-success/contributors-gitlab-com#192 where the @gitlab-bot creates resolvable discussion threads instead of simple comments when thanking users for labeling merge requests. These resolvable threads prevent merging until they are manually resolved.
Problem
When users use the bot to label merge requests, the bot responds with a "thank you" message using the start_thread method, which creates a resolvable discussion thread via the /discussions API endpoint. This blocks merge requests until the thread is manually resolved.
Solution
-
Added
create_notemethod toGitlabRestServicethat uses the/notesendpoint instead of/discussions -
Added
create_notewrapper method toManageableConcernwith the same interface asstart_thread -
Updated the
labelaction inManageMergeRequestControllerto usecreate_noteinstead ofstart_thread -
Maintained backward compatibility by keeping
start_threadfor other actions where discussion threads are appropriate (help requests, review requests)
Key Changes
Files Modified:
-
contributors/app/services/gitlab_rest_service.rb- Addedcreate_notemethod -
contributors/app/controllers/concerns/manageable_concern.rb- Addedcreate_notewrapper -
contributors/app/controllers/api/v1/manage_merge_request_controller.rb- Updatedlabelaction -
contributors/spec/services/gitlab_rest_service_spec.rb- Added comprehensive tests -
contributors/spec/requests/api/v1/manage_merge_request_controller_spec.rb- Updated tests
API Endpoint Differences:
-
Before:
POST /projects/:id/merge_requests/:iid/discussions(creates resolvable threads) -
After:
POST /projects/:id/merge_requests/:iid/notes(creates simple comments)
Testing
-
✅ Added comprehensive tests for the newcreate_notemethod -
✅ Updated controller tests to verifylabelaction usescreate_note -
✅ Ensured backward compatibility tests forhelpandrequest_reviewactions -
✅ Added error handling tests
Impact
✅ Bot's "thank you for labeling" messages no longer create resolvable threads✅ Messages still appear as comments with proper attribution✅ Merge requests are no longer blocked by bot's thank you messages✅ Other bot functionality (help requests, review requests) remains unchanged✅ Fully backward compatible
Related Issues
Closes gitlab-org/developer-relations/contributor-success/contributors-gitlab-com#192