500 error when creating a merge request that removes a submodule
- Zendesk ticket: https://gitlab.zendesk.com/agent/tickets/11490
- Dev link: None
- GitLab version: 8.1.2 (reproducible on 8.1.4, too).
Expected behavior
If a submodule is removed in a commit and the user creates a merge request, the merge request should be created successfully and be mergeable.
Observed behavior
When a commit removes a submodule creating a merge request produces a 500 error. If such a commit is pushed to an existing merge request it is mergeable but the diff breaks.
The error in the logs is:
Completed 500 Internal Server Error in 484ms (ActiveRecord: 7.1ms)
ActionView::Template::Error (undefined method `path' for nil:NilClass):
3: - if diff_file.diff.submodule?
4: %span
5: - submodule_item = project.repository.blob_at(@commit.id, diff_file.file_path)
6: = submodule_link(submodule_item, @commit.id, project.repository)
7: - else
8: %span
9: - if diff_file.deleted_file
app/helpers/submodule_helper.rb:6:in `submodule_links'
app/helpers/diff_helper.rb:157:in `submodule_link'
app/views/projects/diffs/_file.html.haml:6:in `_app_views_projects_diffs__file_html_haml___1653267349141469784_70194922535560'
app/views/projects/diffs/_diffs.html.haml:22:in `block in _app_views_projects_diffs__diffs_html_haml__1830652150926553288_70194905898140'
app/views/projects/diffs/_diffs.html.haml:17:in `each'
app/views/projects/diffs/_diffs.html.haml:17:in `each_with_index'
app/views/projects/diffs/_diffs.html.haml:17:in `_app_views_projects_diffs__diffs_html_haml__1830652150926553288_70194905898140'
app/views/projects/merge_requests/_new_submit.html.haml:37:in `_app_views_projects_merge_requests__new_submit_html_haml___1221975262021238384_70194878935740'
app/views/projects/merge_requests/new.html.haml:5:in `_app_views_projects_merge_requests_new_html_haml___3650664875616120466_70194878630920'
Steps to reproduce:
- Add a submodule to a test repo.
- Commit this to master.
- Check out a branch.
- Delete the submodule, including the entry from
.gitmodules
. - Commit and push.
- Attempt to open a merge request and observe the 500 error.
cc/ @DouweM Can you please look in to this?