Skip to content

The API for obtaining deployed merge requests does not appear to use pagination

The code for this API is as follows (in lib/api/deployments.rb):

desc 'Get all merge requests of a deployment' do
  detail 'This feature was introduced in GitLab 12.7.'
  success Entities::MergeRequestBasic
end
params do
  requires :deployment_id, type: Integer, desc: 'The deployment ID'
  use :merge_requests_base_params
end
                                                                                            
get ':id/deployments/:deployment_id/merge_requests' do
  authorize! :read_deployment, user_project
                                                                                            
  mr_params = declared_params.merge(deployment_id: params[:deployment_id])
  merge_requests = MergeRequestsFinder.new(current_user, mr_params).execute
                                                                                            
  present merge_requests, { with: Entities::MergeRequestBasic, current_user: current_user }
end

There does not appear to be any pagination applied anywhere. This in turn seems to lead to the API taking forever to respond for certain API calls, such as https://gitlab.com/api/v4/projects/gitlab%2Dorg%2Fgitlab/deployments/52594610/merge_requests.

This is a ~P1 as it blocks teamDelivery from notifying merge requests that have been released, as the API calls needed for this are taking forever to finish.