Error: (undefined method `default_branch' for nil:NilClass) - Error 500 on every page

Summary

After pushing to master branch and creating/merging a merge request gitlab stops working for a specific user. It always shows a 500 while other users are still able to use gitlab as normal. But access to the specific repository results in a 500 for every user.

Steps to reproduce

  1. push to master branch
  2. create merge request (master => release)
  3. click on merge button
  4. => shows a 404 on the projects page and a 500 on all other pages (except the admin area)

Of course this is not always reproducable, but this is the third time it happend.

What is the current bug behavior?

The user which creates the merge request can't use gitlab anymore. Every page results in a 500 or 404 while other users can use gitlab as normal (except the specific repository which will be a 500/404 for everyone)

Relevant logs and/or screenshots

production.log while clicking on merge button

Started POST "/myproject/merge_requests/6/merge" for 10.0.13.103 at 2018-03-21 09:36:12 +0100
Processing by Projects::MergeRequestsController#merge as JSON
  Parameters: {"sha"=>"a4f079da2e21eb8b2cc59d1a0d0d791b2c6a1d80", "commit_message"=>"Merge branch 'master' into 'release'\n\nchore(smoke): allow to fail\n\nSee merge request myproject!6", "merge_when_pipeline_succeeds"=>false, "should_remove_source_branch"=>false, "namespace_id"=>"/", "project_id"=>"docker", "id"=>"6", "merge_request"=>{"merge_when_pipeline_succeeds"=>false}}
Completed 200 OK in 102ms (Views: 0.4ms | ActiveRecord: 38.6ms)
Started GET "/myproject/merge_requests/6.json?serializer=basic" for 10.0.13.103 at 2018-03-21 09:36:12 +0100
Processing by Projects::MergeRequestsController#show as JSON
  Parameters: {"serializer"=>"basic", "namespace_id"=>"/", "project_id"=>"docker", "id"=>"6"}
myproject!6 - Git merge started on JID
Completed 200 OK in 68ms (Views: 0.4ms | ActiveRecord: 29.5ms)
Started POST "/api/v4/internal/allowed" for 127.0.0.1 at 2018-03-21 09:36:12 +0100
Started POST "/api/v4/internal/pre_receive" for 127.0.0.1 at 2018-03-21 09:36:13 +0100
Started POST "/api/v4/internal/post_receive" for 127.0.0.1 at 2018-03-21 09:36:13 +0100
myproject!6 - Git merge finished on JID  commit bff28eda3060bd7106070668d6305f646013bfd5
myproject!6 - Post merge started on JID  with state locked
myproject!6 - Post merge finished on JID  with state merged
myproject!6 - Merge process finished on JID  with state merged
Started GET "/admin/sidekiq/stats" for 10.0.13.104 at 2018-03-21 09:36:13 +0100
Started GET "/myproject/merge_requests/6.json?serializer=basic" for 10.0.13.103 at 2018-03-21 09:36:14 +0100
Processing by ApplicationController#route_not_found as JSON
  Parameters: {"serializer"=>"basic", "unmatched_route"=>"myproject/merge_requests/6"}
Completed 404 Not Found in 11ms (ActiveRecord: 3.0ms)
Started GET "/help" for 127.0.0.1 at 2018-03-21 09:36:16 +0100
Processing by HelpController#index as */*
Completed 200 OK in 53ms (Views: 50.0ms | ActiveRecord: 0.0ms)
Started GET "/myproject/merge_requests/6" for 10.0.13.103 at 2018-03-21 09:36:18 +0100
Processing by ApplicationController#route_not_found as HTML
  Parameters: {"unmatched_route"=>"myproject/merge_requests/6"}
Completed 404 Not Found in 101ms (Views: 84.0ms | ActiveRecord: 8.8ms)
Started GET "/admin/sidekiq/stats" for 10.0.13.104 at 2018-03-21 09:36:18 +0100
Started GET "/myproject/merge_requests/6" for 10.0.13.103 at 2018-03-21 09:36:19 +0100
Processing by ApplicationController#route_not_found as HTML
  Parameters: {"unmatched_route"=>"myproject/merge_requests/6"}
Completed 404 Not Found in 119ms (Views: 100.3ms | ActiveRecord: 8.3ms)
Started GET "/myproject" for 10.0.13.103 at 2018-03-21 09:36:22 +0100
Processing by ApplicationController#route_not_found as HTML
   Parameters: {"unmatched_route"=>"myproject"}

error inside the production.log while trying to access gitlab



ActionView::Template::Error (undefined method `default_branch' for nil:NilClass):
    1: - event = last_push_event
    2: - if event && show_last_push_widget?(event)
    3:   .row-content-block.top-block.hidden-xs.white
    4:     .event-last-push
    5:       .event-last-push-text
  app/models/push_event.rb:106:in `last_push_to_non_root?'
  app/helpers/application_helper.rb:109:in `show_last_push_widget?'
  app/views/projects/_last_push.html.haml:2:in `_app_views_projects__last_push_html_haml__1702220975205412547_70332644478280'
  app/views/dashboard/projects/starred.html.haml:8:in `_app_views_dashboard_projects_starred_html_haml___894380166290798882_70332491082960'
  app/controllers/dashboard/projects_controller.rb:31:in `starred'
  lib/gitlab/i18n.rb:47:in `with_locale'
  lib/gitlab/i18n.rb:53:in `with_user_locale'
  app/controllers/application_controller.rb:325:in `set_locale'
  lib/gitlab/middleware/multipart.rb:95: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/middleware/read_only.rb:31:in `call'
  lib/gitlab/request_context.rb:18:in `call'
  lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'

It seems to be that the widget which is shown after a push to a branch on the top of a page is causing the 500. If I try to access the admin area directly by url I don't get a 500 (because the widget won't be shown in the admin area)

Output of checks

This happens on our Gitlab official docker image

Results of GitLab environment info

Expand for output related to GitLab environment info
System information
System:
Current User:	git
Using RVM:	no
Ruby Version:	2.3.6p384
Gem Version:	2.6.13
Bundler Version:1.13.7
Rake Version:	12.3.0
Redis Version:	3.2.11
Git Version:	2.14.3
Sidekiq Version:5.0.5
Go Version:	unknown

GitLab information Version: 10.5.6 Revision: 4b41d48 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://gitlab.dev-mc.de HTTP Clone URL: http://gitlab.dev-mc.de/some-group/some-project.git SSH Clone URL: git@gitlab.dev-mc.de:some-group/some-project.git Using LDAP: no Using Omniauth: no

GitLab Shell Version: 6.0.3 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 >= 6.0.3 ? ... OK (6.0.3) 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: ... 32/112 ... ok 32/113 ... ok 101/114 ... ok 52/115 ... ok 32/116 ... ok 51/117 ... ok 51/118 ... ok 51/119 ... ok 51/120 ... ok 53/121 ... ok 50/122 ... ok 32/123 ... ok 32/124 ... ok 104/125 ... ok 48/126 ... ok 37/127 ... ok 99/128 ... ok 37/129 ... ok 37/130 ... ok 37/132 ... ok 37/133 ... ok 106/134 ... ok 45/135 ... ok 44/136 ... ok 44/137 ... ok 37/138 ... ok 32/139 ... ok 46/140 ... ok 37/141 ... ok 37/142 ... repository is empty 37/143 ... ok 37/144 ... ok 34/145 ... ok 34/146 ... ok 34/147 ... ok 34/148 ... ok 34/149 ... ok 34/150 ... ok 34/151 ... ok 34/152 ... ok 34/153 ... ok 34/154 ... ok 34/155 ... ok 43/156 ... ok 32/157 ... ok 37/158 ... ok 37/159 ... ok 37/160 ... ok 37/161 ... ok 39/162 ... ok 79/163 ... ok 34/164 ... ok 42/165 ... ok 42/166 ... ok 32/167 ... ok 32/168 ... ok 32/169 ... ok 74/170 ... ok 42/171 ... ok 42/172 ... ok 37/173 ... ok 54/174 ... ok 35/175 ... ok 35/176 ... ok 103/177 ... ok 32/178 ... ok 35/179 ... ok 35/180 ... ok 54/181 ... ok 35/182 ... ok 54/183 ... ok 54/184 ... ok 40/186 ... ok 56/187 ... ok 56/188 ... ok 38/189 ... ok 34/190 ... ok 57/191 ... ok 57/192 ... ok 56/193 ... ok 33/194 ... ok 33/195 ... ok 33/196 ... ok 33/197 ... ok 33/198 ... ok 69/199 ... ok 40/200 ... ok 41/201 ... ok 41/202 ... ok 34/203 ... ok 34/204 ... ok 55/206 ... ok 59/207 ... ok 59/208 ... ok 58/209 ... ok 54/210 ... ok 58/211 ... ok 58/212 ... ok 32/213 ... ok 32/214 ... ok 32/215 ... ok 58/216 ... ok 51/217 ... ok 51/218 ... ok 63/219 ... ok 63/221 ... ok 73/222 ... ok 73/223 ... ok 66/228 ... ok 33/229 ... ok 69/230 ... ok 36/234 ... ok 36/236 ... ok 36/237 ... ok 36/238 ... ok 36/239 ... ok 56/240 ... ok 62/244 ... ok 36/245 ... ok 2/246 ... ok 58/248 ... ok 63/249 ... ok 59/250 ... ok 70/251 ... ok 70/252 ... ok 70/253 ... ok 70/254 ... ok 36/255 ... ok 72/257 ... ok 72/258 ... ok 72/259 ... ok 72/260 ... ok 73/263 ... repository is empty 74/264 ... ok 36/267 ... ok 77/268 ... ok 77/269 ... ok 34/270 ... ok 78/271 ... ok 78/272 ... ok 78/273 ... ok 36/274 ... ok 79/275 ... ok 80/280 ... ok 36/281 ... ok 34/283 ... ok 81/285 ... ok 2/286 ... ok 33/287 ... ok 82/288 ... ok 82/289 ... ok 82/290 ... ok 83/291 ... ok 62/292 ... ok 66/295 ... ok 84/296 ... ok 84/297 ... ok 84/298 ... ok 57/299 ... ok 87/305 ... ok 62/307 ... ok 36/314 ... ok 36/316 ... ok 36/317 ... ok 90/318 ... ok 58/319 ... ok 61/320 ... ok 61/322 ... ok 22/323 ... ok 22/324 ... ok 32/325 ... ok 32/326 ... repository is empty 61/328 ... ok 61/329 ... ok 22/331 ... ok 62/332 ... ok 36/333 ... ok 32/339 ... ok 36/340 ... ok 62/341 ... ok 32/342 ... ok 62/343 ... ok 71/344 ... ok 61/345 ... ok 2/346 ... ok 95/348 ... ok 32/349 ... repository is empty 96/350 ... ok 62/351 ... ok 61/352 ... ok 96/354 ... ok 32/355 ... ok 32/358 ... repository is empty 95/359 ... ok 95/360 ... ok 36/361 ... ok 99/362 ... ok 61/363 ... ok 36/364 ... ok 100/365 ... ok 100/366 ... ok 101/367 ... ok 36/369 ... ok 36/370 ... ok 103/371 ... ok 104/373 ... ok 105/375 ... ok 105/376 ... ok 105/377 ... ok 62/379 ... ok 62/380 ... ok 106/381 ... ok 36/382 ... ok 57/383 ... ok 107/384 ... ok 36/385 ... ok 36/386 ... ok 36/387 ... ok 61/388 ... ok 36/389 ... ok 32/390 ... ok 34/391 ... ok 36/392 ... ok 22/393 ... ok 109/394 ... ok 109/395 ... ok 36/396 ... ok 36/398 ... ok 36/400 ... ok 102/401 ... ok 36/402 ... ok 62/403 ... 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: ... 32/112 ... yes 32/113 ... yes 101/114 ... yes 52/115 ... yes 32/116 ... yes 51/117 ... yes 51/118 ... yes 51/119 ... yes 51/120 ... yes 53/121 ... yes 50/122 ... yes 32/123 ... yes 32/124 ... yes 104/125 ... yes 48/126 ... yes 37/127 ... yes 99/128 ... yes 37/129 ... yes 37/130 ... yes 37/132 ... yes 37/133 ... yes 106/134 ... yes 45/135 ... yes 44/136 ... yes 44/137 ... yes 37/138 ... yes 32/139 ... yes 46/140 ... yes 37/141 ... yes 37/142 ... yes 37/143 ... yes 37/144 ... yes 34/145 ... yes 34/146 ... yes 34/147 ... yes 34/148 ... yes 34/149 ... yes 34/150 ... yes 34/151 ... yes 34/152 ... yes 34/153 ... yes 34/154 ... yes 34/155 ... yes 43/156 ... yes 32/157 ... yes 37/158 ... yes 37/159 ... yes 37/160 ... yes 37/161 ... yes 39/162 ... yes 79/163 ... yes 34/164 ... yes 42/165 ... yes 42/166 ... yes 32/167 ... yes 32/168 ... yes 32/169 ... yes 74/170 ... yes 42/171 ... yes 42/172 ... yes 37/173 ... yes 54/174 ... yes 35/175 ... yes 35/176 ... yes 103/177 ... yes 32/178 ... yes 35/179 ... yes 35/180 ... yes 54/181 ... yes 35/182 ... yes 54/183 ... yes 54/184 ... yes 40/186 ... yes 56/187 ... yes 56/188 ... yes 38/189 ... yes 34/190 ... yes 57/191 ... yes 57/192 ... yes 56/193 ... yes 33/194 ... yes 33/195 ... yes 33/196 ... yes 33/197 ... yes 33/198 ... yes 69/199 ... yes 40/200 ... yes 41/201 ... yes 41/202 ... yes 34/203 ... yes 34/204 ... yes 55/206 ... yes 59/207 ... yes 59/208 ... yes 58/209 ... yes 54/210 ... yes 58/211 ... yes 58/212 ... yes 32/213 ... yes 32/214 ... yes 32/215 ... yes 58/216 ... yes 51/217 ... yes 51/218 ... yes 63/219 ... yes 63/221 ... yes 73/222 ... yes 73/223 ... yes 66/228 ... yes 33/229 ... yes 69/230 ... yes 36/234 ... yes 36/236 ... yes 36/237 ... yes 36/238 ... yes 36/239 ... yes 56/240 ... yes 62/244 ... yes 36/245 ... yes 2/246 ... yes 58/248 ... yes 63/249 ... yes 59/250 ... yes 70/251 ... yes 70/252 ... yes 70/253 ... yes 70/254 ... yes 36/255 ... yes 72/257 ... yes 72/258 ... yes 72/259 ... yes 72/260 ... yes 73/263 ... yes 74/264 ... yes 36/267 ... yes 77/268 ... yes 77/269 ... yes 34/270 ... yes 78/271 ... yes 78/272 ... yes 78/273 ... yes 36/274 ... yes 79/275 ... yes 80/280 ... yes 36/281 ... yes 34/283 ... yes 81/285 ... yes 2/286 ... yes 33/287 ... yes 82/288 ... yes 82/289 ... yes 82/290 ... yes 83/291 ... yes 62/292 ... yes 66/295 ... yes 84/296 ... yes 84/297 ... yes 84/298 ... yes 57/299 ... yes 87/305 ... yes 62/307 ... yes 36/314 ... yes 36/316 ... yes 36/317 ... yes 90/318 ... yes 58/319 ... yes 61/320 ... yes 61/322 ... yes 22/323 ... yes 22/324 ... yes 32/325 ... yes 32/326 ... yes 61/328 ... yes 61/329 ... yes 22/331 ... yes 62/332 ... yes 36/333 ... yes 32/339 ... yes 36/340 ... yes 62/341 ... yes 32/342 ... yes 62/343 ... yes 71/344 ... yes 61/345 ... yes 2/346 ... yes 95/348 ... yes 32/349 ... yes 96/350 ... yes 62/351 ... yes 61/352 ... yes 96/354 ... yes 32/355 ... yes 32/358 ... yes 95/359 ... yes 95/360 ... yes 36/361 ... yes 99/362 ... yes 61/363 ... yes 36/364 ... yes 100/365 ... yes 100/366 ... yes 101/367 ... yes 36/369 ... yes 36/370 ... yes 103/371 ... yes 104/373 ... yes 105/375 ... yes 105/376 ... yes 105/377 ... yes 62/379 ... yes 62/380 ... yes 106/381 ... yes 36/382 ... yes 57/383 ... yes 107/384 ... yes 36/385 ... yes 36/386 ... yes 36/387 ... yes 61/388 ... yes 36/389 ... yes 32/390 ... yes 34/391 ... yes 36/392 ... yes 22/393 ... yes 109/394 ... yes 109/395 ... yes 36/396 ... yes 36/398 ... yes 36/400 ... yes 102/401 ... yes 36/402 ... yes 62/403 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.3.6) Git version >= 2.9.5 ? ... yes (2.14.3) Git user has default SSH configuration? ... yes Active users: ... 15

Checking GitLab ... Finished

Edited Jun 23, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading