Skip to content

Forked project settings return 500 when original project is deleted

Summary

If you fork a project and the project you forked from is deleted accessing the settings will return a 500 error on the forked project.

Steps to reproduce

  1. Create a project, say project original
  2. Fork a project, say fork
  3. Removing original will not remove the fork relationship from fork and when accessing settings it will return 500.

What is the current bug behavior?

Fork retains the fork relationship

What is the expected correct behavior?

Fork relationship should be removed when the project is removed or we should handle the exception:

https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/helpers/projects_helper.rb#L143-144

 if project.forked?
      project.forked_from_project.visibility_level > Gitlab::VisibilityLevel::PRIVATE unless project.forked_from_project

Relevant logs and/or screenshots

NoMethodError: undefined method `visibility_level' for nil:NilClass
  from app/helpers/projects_helper.rb:133:in `can_change_visibility_level?'
  from app/helpers/projects_helper.rb:598:in `project_permissions_panel_data'
  from app/views/projects/edit.html.haml:80:in `block in _app_views_projects_edit_html_haml___4520380376854424979_69852716408760'
  from action_view/helpers/capture_helper.rb:38:in `block in capture'
  from action_view/helpers/capture_helper.rb:202:in `with_output_buffer'
  from action_view/helpers/capture_helper.rb:38:in `capture'
  from action_view/helpers/form_helper.rb:444:in `form_for'
  from app/views/projects/edit.html.haml:79:in `_app_views_projects_edit_html_haml___4520380376854424979_69852716408760'
  from action_view/template.rb:145:in `block in render'
  from active_support/notifications.rb:166:in `instrument'
  from action_view/template.rb:333:in `instrument'
  from action_view/template.rb:143:in `render'

Results of GitLab environment info

Reproduced on GitLab.com