Skip to content

Save external_identifiers on ImportFailure for file import relations

James Nutt requested to merge jnutt/link-import-failure-to-iid into master

What does this MR do and why?

Save external_identifiers on ImportFailure for file import relations

The FileImport model has a field for tracking the external identifier associated with a failed record import. This field is used for other importers such as GitHub and BitBucket, but not file-based import.

This MR tracks the IID associated with issues, merge requests, milestones and CI pipelines that fail to import. It also lays the groundwork for tracking identifiers for other relations, should the need arise and we can identify a unique key.

Related issue: #434945 (closed)

Changelog: changed

How to set up and validate locally

  1. Enable the "GitLab export" import source in /admin/application_settings.
  2. Import a new project and select "GitLab export."
  3. Import the attached project export.
  4. In the Rails console, confirm that the recorded IIDs match the IID in the imported archive. You can extract the archive and view the NDJSON files in the tree folder.
p = Project.last
p.import_failures.count
# should eq 4
p.import_failures.collect { |f| [f.relation_key, f.external_identifiers] }
# [["milestones", {"iid"=>99}],
# ["issues", {"iid"=>31}],
# ["merge_requests", {"iid"=>1}],
# ["ci_pipelines", {"iid"=>1234}]]

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by James Nutt

Merge request reports