Skip to content

Direct Transfer - Continue to import nested records when an error is raised

When importing a merge request that includes multiple notes and diff notes, if an error occurs during the migration of a diff note, the merge request and its associated notes will still be imported and linked to a placeholder user. However, the diff note itself will not be created; the remaining nested records will also not be created, and the placeholder references for the merge request and notes will not be saved. As a result, they are not reassigned. (this was fixed by !173791 (merged))

Visual example:

MergeRequest - Imported
 - Note1 - Imported
 - Note2 - Imported
 - Note3 - Imported
 - DiffNote1 <-- Error
 - DiffNote2
 - Event1
 - Event2

MergeRequest, Note1, Note2, and Note3 are imported; everything below them isn't created.

In most cases with nested records, this issue should not arise because Direct Transfer invokes record.valid? before saving the nested record. However, there are instances where record.valid? might return true yet still result in an error. For example, when saving a DiffNote, we may encounter the DiffNote::NoteDiffFileCreationError: "Failed to find diff file" error.

Proposed solution

Invalidate DiffNote records if we would not be able to create a diff note file for them #505712 (comment 2257939288). We should involve groupsource code in the solution and reviews #505712 (comment 2282059482).

Edited by 🤖 GitLab Bot 🤖