Skip to content

Allow duplicate award emoji when Importing

What does this MR do?

This MR fixes a case of project's relation (a merge request, for example) failing to be imported, due to duplicate award emoji attempting to be saved.

Consider the following scenario:

  1. A user leaves a note on an MR
  2. 2 different users leave a 👍 emoji on that note
  3. Previous 2 users get deleted, and replaced by Ghost User, so now 2 award emoji are duplicates with the same name and user id of ghost user, since this is the allowed case in AwardEmoji model validation https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/award_emoji.rb#L18

image

  1. This project gets exported and imported at a new destination
  2. Since the Ghost User is not a member of mentioned project, when project is imported, all occurrences of Ghost User user_id get replaced with importer user id. Because of that, there are 2 award emoji with the same name and user_id which fails AwardEmoji model validation https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/models/award_emoji.rb#L18
  3. This results in the project relation failing to be created (merge request in this case. but this can be anything that has award emojis association)

This change allows duplicate award emoji when importing, similar to ghost user behaviour.

Here is a demonstration of what is going to happen to those duplicate emoji when Project Import is complete:

screencast_2020-04-01_17-36-02

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports