Skip to content

Fix bug rendering snippet activity

What does this MR do?

I recently came up with https://sentry.gitlab.net/gitlab/gitlabcom/issues/2474015. It seems we have a bug rendering user's activity feed when there is snippet activity, specifically personal snippet activity. The problem is in Event#project_snippet_note?.

def project_snippet_note?
  note? && target && target.for_snippet?
end

In that method we call for_snippet? and would return true for both project and personal snippets. Therefore, when we have an event associated with a personal snippet, that method will return true and we will end up calling the url helper project_snippet_url with a personal snippet, and that will fail with a 500 error.

In this MR, we fix the method and also rewrite the url generation method in the events helper to call gitlab_snippet_url, getting the appropriate url based on the snippet type.

Hot to reproduce the bug

  • Create a personal snippet and add a comment to it
  • Now, browse your user's activity in /<username>/activity
  • The page won't show any activity because the request returns a 500

Does this MR meet the acceptance criteria?

Conformity

Merge request reports