Skip to content

Do not render discussion notes if they don't have noteable object

username-removed-85284 requested to merge 4burgos/gitlab-ce:noteable into master

It can be that for some notes, noteable object is missing - in that case, trying to access MR page will result in 500.

The example stacktrace that this was causing:

ActionView::Template::Error (undefined method `short_id' for nil:NilClass):
     8:     %div
     9:       = link_to_member(@project, note.author, avatar: false)
    10:       started a discussion on commit
    11:       = link_to(note.noteable.short_id, namespace_project_commit_path(note.project.namespace, note.project, note.noteable), class: 'monospace')
    12:     .last-update.hide.js-toggle-content
    13:       - last_note = discussion_notes.last
    14:       last updated by
  app/views/projects/notes/discussions/_commit.html.haml:11:in `_app_views_projects_notes_discussions__commit_html_haml__3941093634626721150_70211453360220'
  app/views/projects/notes/_discussion.html.haml:13:in `_app_views_projects_notes__discussion_html_haml___308611826505619652_70211453242900'
  app/views/projects/notes/_notes.html.haml:7:in `block in _app_views_projects_notes__notes_html_haml___3579999865745322754_70211450085080'
  app/views/projects/notes/_notes.html.haml:2:in `each'
  app/views/projects/notes/_notes.html.haml:2:in `_app_views_projects_notes__notes_html_haml___3579999865745322754_70211450085080'
  app/views/projects/notes/_notes_with_form.html.haml:2:in `_app_views_projects_notes__notes_with_form_html_haml__2559747028316399085_70211449885960'
  app/views/projects/merge_requests/_discussion.html.haml:8:in `_app_views_projects_merge_requests__discussion_html_haml__1683507126214788952_70211449370780'
  app/views/projects/merge_requests/_show.html.haml:72:in `_app_views_projects_merge_requests__show_html_haml__4370444506482625585_70211449827400'
  app/views/projects/merge_requests/show.html.haml:1:in `_app_views_projects_merge_requests_show_html_haml___2328464185082279631_70211451245400'
  app/controllers/projects/merge_requests_controller.rb:51:in `show'

Merge request reports