Convert attributes' empty strings to nil before doing object lookup in ImportExport::BaseObjectBuilder
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: niland 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).
-
GroupObjectBuilderuses 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
Edited by Haris Delalić