URL of invalid group leads to 500 instead of 404

When linking to to an invalid URL, a 500 is raised instead of a 404. This a affects gitlab.com (8.1.2) and current master.

The following error is raised in views/groups/show.html.haml::6:

No route matches {:action=>"show", :controller=>"groups", :format=>:atom, :id=>nil, :private_token=>"xyz"} missing required keys: [:id]

Line 6 is the last line of following snippet:

- unless can?(current_user, :read_group, @group)
  - @disable_search_panel = true
= content_for :meta_tags do
  - if current_user
    = auto_discovery_link_tag(:atom, group_url(@group, format: :atom, private_token: current_user.private_token), title: "#{@group.name} activity")

Steps to reproduce

Expected bahavior

  • Because group is invalid, a 404 should be raised.