500 error when opening open/merged merge requests imported from Github
Summary
(Probably a follow-up of https://gitlab.com/gitlab-org/gitlab-ce/issues/38289)
I have imported a project from Github with merge requests. When I try to open the Merge requests that are in the open/merged state (the ones that are closed are opening fine), it throws a 500 error.
Steps to reproduce
Import a project from Github with some open/closed/merged pull requests.
What is the current bug behavior?
Error 500
What is the expected correct behavior?
Should display the MR.
Relevant logs and/or screenshots
==> /var/log/gitlab/gitlab-rails/production.log <==
Started GET "/eng/ninevirt/ninevirt/merge_requests/299" for 217.150.242.121 at 2017-10-10 08:33:00 +0200
Processing by Projects::MergeRequestsController#show as HTML
Parameters: {"namespace_id"=>"eng/ninevirt", "project_id"=>"ninevirt", "id"=>"299"}
Completed 500 Internal Server Error in 164ms (Views: 126.1ms | ActiveRecord: 8.1ms)
NoMethodError (undefined method `commits_count' for nil:NilClass):
app/models/merge_request.rb:226:in `commits_count'
app/controllers/projects/merge_requests_controller.rb:65:in `block (2 levels) in show'
app/controllers/projects/merge_requests_controller.rb:59:in `show'
lib/gitlab/i18n.rb:46:in `with_locale'
lib/gitlab/i18n.rb:52:in `with_user_locale'
app/controllers/application_controller.rb:326:in `set_locale'
lib/gitlab/middleware/multipart.rb:93:in `call'
lib/gitlab/request_profiler/middleware.rb:14:in `call'
lib/gitlab/middleware/go.rb:17:in `call'
lib/gitlab/etag_caching/middleware.rb:11:in `call'
lib/gitlab/request_context.rb:18:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Ubuntu 16.04 Current User: git Using RVM: no Ruby Version: 2.3.5p376 Gem Version: 2.6.13 Bundler Version:1.13.7 Rake Version: 12.0.0 Redis Version: 3.2.5 Git Version: 2.13.5 Sidekiq Version:5.0.4 Go Version: unknownGitLab information Version: 10.0.3 Revision: 8895150 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https://gitlab.nine.ch HTTP Clone URL: https://gitlab.nine.ch/some-group/some-project.git SSH Clone URL: git@gitlab.nine.ch:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: cas3
GitLab Shell Version: 5.9.0 Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab Shell ...GitLab Shell version >= 5.9.0 ? ... OK (5.9.0) Repo base directory exists? default... yes Repo storage directories are symlinks? default... no Repo paths owned by git:root, or git:git? default... yes Repo paths access is drwxrws---? default... yes hooks directories in repos are links: ... 22/2 ... ok 22/3 ... ok 22/4 ... ok 21/6 ... ok 21/7 ... ok 9/8 ... ok 23/10 ... ok 23/11 ... ok 23/12 ... ok 23/13 ... ok 23/14 ... ok 16/15 ... ok 21/16 ... repository is empty 21/17 ... repository is empty 19/18 ... ok Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Sidekiq ...
Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 22/2 ... yes 22/3 ... yes 22/4 ... yes 21/6 ... yes 21/7 ... yes 9/8 ... yes 23/10 ... yes 23/11 ... yes 23/12 ... yes 23/13 ... yes 23/14 ... yes 16/15 ... yes 21/16 ... yes 21/17 ... yes 19/18 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... yes (2.3.5) Git version >= 2.7.3 ? ... yes (2.13.5) Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1507617390 sudo mv /var/opt/gitlab/.ssh/authorized_keys.lock ~/gitlab-check-backup-1507617390 For more information see: doc/ssh/README.md in section "SSH on the GitLab server" Please fix the error above and rerun the checks. Active users: ... 11
Checking GitLab ... Finished