Cannot open merged request (error 500)
An old merged request which source project deleted -- return error 500
An old merge request which was created and merged 11 months ago and its source project has been deleted.
When access this merged request it returns page error 500.
Steps to reproduce
- Open merge request that has already merged long time ago. And its source project has been deleted.
- some of them cannot open and return 500
What is the current bug behavior?
After click link to see detail of merged request, it return 500
What is the expected correct behavior?
If source project has been deleted, it must shows (removed) word.
Relevant logs and/or screenshots
It is failing when looking up the source repository:
Completed 500 Internal Server Error in 86ms (ActiveRecord: 10.3ms)
NoMethodError (undefined method `repository' for nil:NilClass):
app/models/merge_request.rb:749:in `fetch_ref'
app/models/merge_request.rb:764:in `ensure_ref_fetched'
app/controllers/projects/merge_requests_controller.rb:646: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
Possible fixes
The line that it is falling on is: source_project.repository.path_to_repo, in the code below
def fetch_ref
target_project.repository.fetch_ref(
source_project.repository.path_to_repo,
"refs/heads/#{source_branch}",
ref_path
)
end