Skip to content

Importing a project from GitLab failure (invalid base64) if project contains at least one Merge Request with a binary file in it

Summary

When migrating a project from one GitLab server to another the import process crashes.
Tested on GitLab Enterprise Edition 10.6.3-ee

Steps to reproduce

Go to a GitLab repository which had a Merge Request with at least one binary file in it.
Export via Settings -> Export project
Go to the target GitLab server and create a new project selecting Import project -> GitLab export
The process begins; a file is being uploaded; during importing phase an error occurs with label:

Error importing repository into mackam/this-project-should-fail-import - invalid base64

Example Project

Any project where there is at least one binary file in at least one Merge Request.
This MR does not have to be merged. Its state does not matter.

What is the current bug behavior?

This bug prevent user from successfully importing a project from another GitLab server.

What is the expected correct behavior?

GitLab should be able to successfully import a project with binary files in Merge Requests.

Relevant logs and/or screenshots

A sample merge request with a binary file: merge_request_with_binary_file

Error during importing process: failure_during_import

Possible fixes

A temporary solution to import such a project is to open the exported archive and edit the file project.json.
I had to migrate a huge project where this json file was about 200MB so I have created a small Java tool which went through JSON nodes and searched for:

"merge_requests": [
	"merge_request_diff": [
		"merge_request_diff_files": [
		...,
		{
			"binary":"true"
		},
		...
		]
	]
]

If there was at least one merge_request_diff_files entry with binary == true in a single merge_request, this whole object had to be removed from the json.
After this treatment the project.json file had to be put back to the archive and then the import process was successful.

/label ~bug

Edited by Maciej Kaminski