Skip to content

Designs: return an error if uploading designs with duplicate names

Sushil khanchi requested to merge khanchi97/gitlab:khanchi-designs-patch into master

What does this MR do?

This MR adds a fix for #235227 (closed) and a partial fix for #219113 (closed). See #219113 (comment 354495098)

Now, SaveDesignsService will validate that files passed to it have unique file names and produce an error response if not #219113 (comment 354825433) This behavior will save us from hitting the PG::UniqueViolation, as now it won't try to write duplicate entries in the database.

This MR only fixes the following two issues:

  1. Upload a single testing.jpg file first, and then attempt to upload two different testing.jpg files, we get the following error:
PG::UniqueViolation

ERROR:  duplicate key value violates unique constraint "design_management_designs_versions_uniqueness"
DETAIL:  Key (design_id, version_id)=(7505, 6712) already exists.
  1. When there are no existing testing.jpg designs uploaded, and I try to upload two testing.jpg files, I get:

Gitlab::Git::Index::IndexError (A file with this name already exists):

But there are other issues as well related to the uploading of designs (mentioned by @.luke here #219113 (comment 354825433)) which we need to take care of (maybe after this MR):

By @luke :

  • Even after we decouple design identity with its filename (#213782 and #213783) I think we would still have this problem when creating files.

  • We should also handle when original_filenames are stripped of special characters #219113 (comment 360806168)

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 Markus Koller

Merge request reports