Skip to content

Merged request giving 500 on project import

Summary

Merged requests are not accessible when a we fork a project and then create a merge request in forked project to source project and merge it in source project. Then if we try to import that project on a new instance and try to access the merge request it redirects to 500 page.

Steps to reproduce

Steps to reproduce:

  1. Create a project on GitLab instance A

  2. Fork this project

  3. Create a MR in forked project to source project and merge it in source project.

  4. Export source repository

  5. Import in on GitLab instance B

  6. Try accessing the merged request

Expected behavior

It should show the merged requests

Actual behavior

Giving 500 error

Relevant logs and/or screenshots

==> /var/log/gitlab/gitlab-rails/production.log <==
Started GET "/root/forkimport/merge_requests/1" for 103.233.94.10 at 2016-12-29 05:03:24 -0500
Processing by Projects::MergeRequestsController#show as HTML
  Parameters: {"namespace_id"=>"root", "project_id"=>"forkimport", "id"=>"1"}
Completed 500 Internal Server Error in 57ms (ActiveRecord: 8.3ms)

NoMethodError (undefined method `repository' for nil:NilClass):
  app/models/merge_request.rb:753:in `fetch_ref'
  app/models/merge_request.rb:768:in `ensure_ref_fetched'
  app/controllers/projects/merge_requests_controller.rb:636:in `ensure_ref_fetched'
  lib/gitlab/middleware/multipart.rb:93:in `call'
  lib/gitlab/request_profiler/middleware.rb:15:in `call'
  lib/gitlab/middleware/go.rb:16:in `call'



==> /var/log/gitlab/gitlab-workhorse/current <==
2016-12-29_10:03:24.59739 2016/12/29 05:03:24 ErrorPage: serving predefined error page: 500
2016-12-29_10:03:24.59767 139.59.18.166 @ - - [2016-12-29 05:03:24.530034544 -0500 EST] "GET /root/forkimport/merge_requests/1 HTTP/1.1" 500 2648 "http://139.59.18.166/root/forkimport/merge_requests?scope=all&state=merged" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" 0.067586

Results of GitLab environment info

Tested this issue on 2 different version 8.12, 8.13.6 and 8.15.2

Below is the issue

bug

ZD: https://gitlab.zendesk.com/agent/tickets/53171

Related: https://gitlab.com/gitlab-org/gitlab-ce/issues/27600

cc// @adamniedzielski @MrChrisW @dewetblomerus