Designs: return an error if uploading designs with duplicate names
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:
- Upload a single
testing.jpg
file first, and then attempt to upload two differenttesting.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.
- When there are no existing
testing.jpg
designs uploaded, and I try to upload twotesting.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_filename
s are stripped of special characters #219113 (comment 360806168)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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