Getting 500 page when editing and committing file, with No-One Allowed to Push Option
Summary
I am a admin of a new self-hosted version of GitLab CE 10.6.0 at my workplace, I have a project that has a Repo sitting that No-One is Allowed to Push. So testing this feature out, if I go edit a file from the file list, add a new line. I can see at the bottom. The branch is auto populated with patch-1 in the field, if I change this back to master and hit Commit Changes, I get a 500 page. I know this isnt the expected use case but it shouldnt error. This bug happens on GitLab.com
Steps to reproduce
- Under Project settings
- Click Repository and expand the Protected Branches area
- Give a protected branch the setting of No-One under Allowed to Push
- Go to Repository > Files, click on a file to view (ex. Readme.md)
- Next click Edit
- Next add a new line with text (ex. Testing Testing)
- Change Target Branch from patch-1 (populated branch name) to master (protected branch)
- Hit Commit Changes and you get 500 page
Example Project
I confirmed this bug in my project test-project on GitLab.com
What is the current bug behavior?
Throws 500 error
What is the expected correct behavior?
Even though this use case should not happen, it should prevent from throwing error
Relevant logs and/or screenshots
This is from my self-hosted production.log
Completed 500 Internal Server Error in 24ms (ActiveRecord: 2.8ms)
NoMethodError (undefined method `branch_allows_maintainer_push?' for nil:NilClass):
lib/gitlab/user_access.rb:66:in `can_push_to_branch?'
lib/gitlab/cache/request_cache.rb:76:in `block (3 levels) in request_cache'
lib/gitlab/cache/request_cache.rb:76:in `fetch'
lib/gitlab/cache/request_cache.rb:76:in `block (2 levels) in request_cache'
app/services/commits/create_service.rb:47:in `validate_permissions!'
app/services/commits/create_service.rb:39:in `validate!'
app/services/files/update_service.rb:17:in `validate!'
app/services/commits/create_service.rb:15:in `execute'
app/controllers/concerns/creates_commit.rb:23:in `create_commit'
app/controllers/projects/blob_controller.rb:62:in `update'
lib/gitlab/i18n.rb:50:in `with_locale'
lib/gitlab/i18n.rb:56:in `with_user_locale'
app/controllers/application_controller.rb:330: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/controller.rb:28:in `call'
lib/gitlab/middleware/read_only.rb:16:in `call'
lib/gitlab/request_context.rb:18:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:27:in `call'
lib/gitlab/middleware/release_env.rb:10:in `call'




