NoMethodError: undefined method `sha' for nil:NilClass

Summary

Merge reqeuests can't be displayed.

NoMethodError: undefined method `sha' for nil:NilClass

Steps to reproduce

Open an older merge request.

What is the current bug behavior?

We get a 500er error.

What is the expected correct behavior?

See the merge request content.

Relevant logs and/or screenshots

Started GET "/acx-dotnet/Vektoren/merge_requests/4" for 192.168.50.35 at 2017-09-25 10:28:00 +0200
Processing by Projects::MergeRequestsController#show as HTML
Parameters: {"namespace_id"=>"acx-dotnet", "project_id"=>"Vektoren", "id"=>"4"}
Completed 500 Internal Server Error in 38ms (ActiveRecord: 4.5ms)
NoMethodError (undefined method `sha' for nil:NilClass):
lib/gitlab/git/repository.rb:808:in `with_repo_branch_commit'
lib/gitlab/git/repository.rb:834:in `fetch_source_branch'
app/models/repository.rb:1033:in `fetch_source_branch'
app/models/merge_request.rb:970:in `write_ref'
app/models/merge_request.rb:803:in `fetch_ref'
app/models/merge_request.rb:822:in `ensure_ref_fetched'
app/controllers/projects/merge_requests/application_controller.rb:16:in `ensure_ref_fetched'
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'

Results of GitLab environment info

Expand for output related to GitLab environment info
sudo gitlab-rake gitlab:env: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: unknown

GitLab information Version: 10.0.1 Revision: 2417795 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https://git.nsc-gmbh.de HTTP Clone URL: https://git.nsc-gmbh.de/some-group/some-project.git SSH Clone URL: git@git.nsc-gmbh.de:some-group/some-project.git Using LDAP: no Using Omniauth: no

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
sudo gitlab-rake gitlab:check SANITIZE=true

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: ... 6/2 ... ok 10/4 ... ok 6/7 ... ok 10/8 ... ok 10/11 ... ok 10/12 ... ok 10/13 ... ok 6/15 ... ok 10/17 ... ok 10/18 ... ok 10/19 ... ok 10/22 ... ok 10/23 ... ok 6/24 ... ok 4/25 ... ok 5/26 ... ok 5/27 ... ok 3/29 ... ok 3/30 ... ok 7/31 ... ok 3/32 ... ok 4/33 ... ok 7/34 ... ok 7/35 ... ok 6/36 ... ok 3/37 ... ok 3/38 ... ok 3/39 ... ok 6/40 ... ok 6/42 ... ok 4/43 ... ok 6/45 ... ok 6/48 ... ok 6/49 ... ok 6/50 ... ok 6/51 ... ok 3/53 ... ok 6/54 ... ok 4/55 ... ok 10/56 ... ok 6/57 ... ok 3/58 ... ok 5/59 ... ok 6/60 ... ok 10/61 ... ok 10/63 ... ok 6/64 ... ok 15/65 ... ok 10/66 ... ok 6/67 ... ok 5/68 ... ok 3/69 ... ok 6/70 ... ok 3/71 ... ok 3/72 ... ok 5/73 ... ok 3/74 ... ok 10/75 ... ok 3/76 ... ok 6/77 ... ok 3/78 ... ok 10/79 ... ok 3/80 ... ok 6/81 ... ok 6/82 ... ok 3/83 ... ok 3/84 ... 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: ... 6/2 ... yes 10/4 ... yes 6/7 ... yes 10/8 ... yes 10/11 ... yes 10/12 ... yes 10/13 ... yes 6/15 ... yes 10/17 ... yes 10/18 ... yes 10/19 ... yes 10/22 ... yes 10/23 ... yes 6/24 ... yes 4/25 ... yes 5/26 ... yes 5/27 ... yes 3/29 ... yes 3/30 ... yes 7/31 ... yes 3/32 ... yes 4/33 ... yes 7/34 ... yes 7/35 ... yes 6/36 ... yes 3/37 ... yes 3/38 ... yes 3/39 ... yes 6/40 ... yes 6/42 ... yes 4/43 ... yes 6/45 ... yes 6/48 ... yes 6/49 ... yes 6/50 ... yes 6/51 ... yes 3/53 ... yes 6/54 ... yes 4/55 ... yes 10/56 ... yes 6/57 ... yes 3/58 ... yes 5/59 ... yes 6/60 ... yes 10/61 ... yes 10/63 ... yes 6/64 ... yes 15/65 ... yes 10/66 ... yes 6/67 ... yes 5/68 ... yes 3/69 ... yes 6/70 ... yes 3/71 ... yes 3/72 ... yes 5/73 ... yes 3/74 ... yes 10/75 ... yes 3/76 ... yes 6/77 ... yes 3/78 ... yes 10/79 ... yes 3/80 ... yes 6/81 ... yes 6/82 ... yes 3/83 ... yes 3/84 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.3 ? ... Exception: undefined method run_command' for SystemCheck::App::RubyVersionCheck:Class Did you mean? run_commands Git version >= 2.7.3 ? ... Exception: undefined method run_command' for SystemCheck::App::GitVersionCheck:Class Did you mean? run_commands Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1506328541 sudo mv /var/opt/gitlab/.ssh/authorized_keys.lock ~/gitlab-check-backup-1506328541 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

Sentry error: https://sentry.gitlap.com/gitlab/gitlabcom/issues/46145/

Edited by Stan Hu