Skip to content

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_note method to GitlabRestService that uses the /notes endpoint instead of /discussions
  • Added create_note wrapper method to ManageableConcern with the same interface as start_thread
  • Updated the label action in ManageMergeRequestController to use create_note instead of start_thread
  • Maintained backward compatibility by keeping start_thread for other actions where discussion threads are appropriate (help requests, review requests)

Key Changes

Files Modified:

  • contributors/app/services/gitlab_rest_service.rb - Added create_note method
  • contributors/app/controllers/concerns/manageable_concern.rb - Added create_note wrapper
  • contributors/app/controllers/api/v1/manage_merge_request_controller.rb - Updated label action
  • 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 new create_note method
  • Updated controller tests to verify label action uses create_note
  • Ensured backward compatibility tests for help and request_review actions
  • 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

Merge request reports

Loading