Skip to content

500 error when viewing a MR and the commit object cannot be found

Zendesk: https://gitlab.zendesk.com/agent/tickets/51828

For whatever reason, a Rugged error like the follow can occur. When it does, we should handle it gracefully. A MR page should not produce a 500 error, but should display a usable error message and still load the discussion and description

Completed 500 Internal Server Error in 217ms (ActiveRecord: 9.0ms)

Rugged::OdbError (Object not found - no match for id (49fe041c313fa7285016a6386db8abf97102507d)): 
app/models/repository.rb:1188:in `merge_base' 
app/models/repository.rb:1188:in `merge_base' 
app/models/project.rb:528:in `merge_base_commit' 
app/models/merge_request.rb:283:in `branch_merge_base_commit' 
app/models/merge_request.rb:217:in `diff_base_commit' 
app/controllers/projects/merge_requests_controller.rb:626:in `define_new_vars' 
app/controllers/projects/merge_requests_controller.rb:231:in `new' 
lib/gitlab/request_profiler/middleware.rb:15:in `call' 
lib/gitlab/middleware/go.rb:16:in `call' 
lib/gitlab/middleware/readonly_geo.rb:29:in `call'

Somewhat related to https://gitlab.com/gitlab-org/gitlab-ce/issues/17238 and https://gitlab.com/gitlab-org/gitlab-ce/issues/15261