500 when deleting repository file in read-only

Summary

(Summarize the bug encountered concisely)

Steps to reproduce

  1. create a project and some files
  2. in database, set repository_read_only to true for the project
  3. navigate to the project UI, and delete a file via the UI's delete button
  4. observe a 500 error

Example Project

I'm self-hosting gitlab-foss v12.1.9 locally so can't really shown an example on gitlab.com

What is the current bug behavior?

image

ActionView::Template::Error (No route matches {:action=>"signatures", :controller=>"projects/commits", :id=>nil, :namespace_id=>"Yuanchen.Lu", :project_id=>"d"}, possible unmatched constraints: [:id]): 
 3:  
 4: - page_title @blob.path, @ref  
 ==> /var/log/gitlab/production.log <== 
 Started GET "/" for 127.0.0.1 at 2019-09-27 14:16:29 +0000 
 Processing by RootController#index as HTML 
 5:  
 6: - signatures_path = namespace_project_signatures_path(namespace_id: @project.namespace.full_path, project_id: @project.path, id: @last_commit) 
 7: .js-signature-container{ data: { 'signatures-path': signatures_path } } 
 8:  
 9: %div{ class: container_class } 
app/views/projects/blob/show.html.haml:6:in `_app_views_projects_blob_show_html_haml__29205383485291357_47422588649720' 
app/controllers/application_controller.rb:117:in `render' 
app/controllers/concerns/creates_commit.rb:43:in `block (2 levels) in create_commit' 
app/controllers/concerns/creates_commit.rb:40:in `create_commit' 
app/controllers/projects/blob_controller.rb:86:in `destroy' 
lib/gitlab/session.rb:11:in `with_session'  

What is the expected correct behavior?

(What you should see instead)

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise.)

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:env:info)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production)

Results of GitLab application Check

 bundle exec rake gitlab:check SANITIZE=true
Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 9.3.0 ? ... OK (9.3.0)
Running /Users/yuanchenlu/Desktop/12.1.9/gitlab-development-kit/gitlab-shell/bin/check
Check GitLab API access: OK
Redis available via internal API: OK

Access to /Users/yuanchenlu/Desktop/12.1.9/gitlab-development-kit/.ssh/authorized_keys: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... LDAP is disabled in config/gitlab.yml

Checking LDAP ... Finished

Checking GitLab App ...

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? ... no
  Try fixing it:
  Install the init script
  For more information see:
  doc/install/installation.md in section "Install Init Script"
  Please fix the error above and rerun the checks.
Init script up-to-date? ... can't check because of previous errors
Projects have namespace: ... 
1/2 ... yes
3/3 ... yes
1/4 ... yes
1/5 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.5.3 ? ... yes (2.6.3)
Git version >= 2.21.0 ? ... yes (2.23.0)
Git user has default SSH configuration? ... no
  Try fixing it:
  mkdir ~/gitlab-check-backup-1569595318
  sudo mv /Users/yuanchenlu/.ssh/id_rsa.pub ~/gitlab-check-backup-1569595318
  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: ... 3

Checking GitLab App ... Finished


Checking GitLab subtasks ... Finished

I don't think the problem has any ties to SSH / init script not being configured

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

Assignee Loading
Time tracking Loading