Skip to content

Update NdjsonPipeline#transform to return if data is nil

George Koltsov requested to merge georgekoltsov/update-ndjson-pipeline into master

What does this MR do and why?

this feature is behind bulk_import_projects feature flag that is currently off by default (and disabled on .com).

This MR fixes a bug where an exception would be raised in NdjsonPipeline#transform because of incoming data being nil. It is used in a GitLab Migration feature https://docs.gitlab.com/ee/user/group/import/ that imports groups and projects with one click.

For example, when importing project does not have push rule, then the contents of downloaded push_rule.ndjson file is nil, which is being read from file and converted into [nil, 0] during extraction, which raises exception NoMethodError: undefined method except for nil here: http://gitlab.com/gitlab-org/gitlab/blob/6e39022e6514273e2f34a764b6db51af3f844a87/lib/gitlab/import_export/base/relation_factory.rb#L51-L51

This MR makes sure that if no data is exported from source, there is no need to raise an exception, just return early and do nothing.

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

  1. Feature.enable(:bulk_import).
  2. Feature.enable(:bulk_import_projects).
  3. Create a top level group and project in it. Do not specify any push rules.
  4. Go to /groups/new#import-group-pane page and enter instance url and access token (needs to be api & read_repository scope).
  5. Select newly created group and click Import.
  6. Wait for Group import to complete and verify bulk_import_failures table. There should be no error coming from PushRulePipeline.

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 George Koltsov

Merge request reports