Visiting epic boards in public groups as a non-logged-in user can fail
Summary
Visiting epic boards in public groups as a non-logged-in user often fails with 500 status code.
This is because visiting epic boards for the first time creates a board automatically. In the process it records a usage event to track the creation of a board. This looks for the current user ID, which is nil
as the user is not logged in.
This bug cannot be reproduced if anyone who is logged in and authorized to create epic boards has visited the epic boards index page at least once.
Steps to reproduce
- Create a new public group,
- Copy the link to the epic boards page from the sidebar (but do not visit it),
- Open a private browser window,
- Paste in and go to the link.
Example Project
It's brittle to provide an example group, as anyone visiting the link while logged in will create a board and stop the bug from occurring. Instead, see the instructions in steps to reproduce
What is the current bug behavior?
User sees a 500.
What is the expected correct behavior?
User should see an epic board.
Possible fixes
The creation of a tracking event shouldn't break a feature for customers. Instead we should simply not track the user id if there isn't one. In other words, edit /ee/app/services/boards/epic_boards/create_service.rb#L23 to include the lonely operator:
track_usage_event(:g_project_management_users_creating_epic_boards, current_user&.id)