Convert empty strings to nil in ImportExport::BaseObjectBuilder
What does this MR do?
There is a bug with Group/Project Import/Export's BaseObjectBuilder
where it is not properly able to find existing objects like labels/milestones if those relations have empty strings as values for attributes (for example, description).
The following scenario will illustrate the problem better:
- Source Group/Project has a label that is being used on an issue board.
- This label has an empty string as a description
- When serialized to json and exported, label's description is going to be
"description" => ""
, as expected - On Import, when the label is created, rails converts
description: ""
todescription: nil
and saves it. - During import when creating a board, we need to find and associate already created label with newly created board (instead of creating one).
-
GroupObjectBuilder
uses 4 attributes to find an existing object.group_id/title/description/created_at
. The lookup usesdescription: ""
and fails to find the right label, sincenil != ""
, which leads to a relation creation failure (since it tries to create a label with the same title, and fails). https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/import_export/group_object_builder.rb#L28-33
Converting any empty strings to nil before doing a lookup is going to solve this problem.
This is currently not a problem for Project Import, because it does not rely on description
to do object lookup https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/import_export/group_project_object_builder.rb#L41-41
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