Project import from S3 remote object storage does not work
Overview
This issue started by testing the project import from remote object storage feature. AWS S3 was chosen for remote object storage.
When trying to import a project export archive, uploaded to an AWS S3 bucket, to gitlab.com, it returns the following response:
400 Bad Request
cloudflare
This applies to both the API by using Insomnia and curl.
- The feature flag is enabled on gitlab.com by default.
- This has also been tested on an on-prem GitLab instance and enabling the FF (
nginxinstead ofcloudflare)
irb(main):007:0> Feature.all.map {|f| [f.name, f.state]}
=> [["multiple_merge_request_assignees", :on], [:import_project_from_remote_file, :on]]
Which remote object storage provider has this feature been tested on?
Details
- The pre-signed URL is generated locally, on a MacOS, using the
brewawslibrary:
$ aws s3 presign s3://import-from-remote-object-storage/2021-06-29_17-32-723_pmm-demo_test-project_export.tar.gz
...
<presigned_url_output>
- The following JSON object is
POSTed to the API endpointhttps://gitlab.com/api/v4/projects/remote-import
{
"url":"<presigned_url_output>",
"path":"pprokic-test-remote-project",
"name": "pprokic Test Remote Project",
"namespace": "pprokic"
}
- With headers
{
Content-Type: application/json,
Private-Token: <token>,
Content-Length: application/gzip
}
- By following the doc example you would receive, even when adding the 2 missing headers
ContentTypeandContentLength:
{"error":"url is missing, path is missing"}
- When fixing the 2 headers to
Content-TypeandContent-Lengthone gets:
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
or nginx in case of self-managed
Proposed Solution
-
Documentation fix: !75158 (merged) - The error
{"error":"url is missing, path is missing"}is caused when thedataattribute is not parsed, which because the headerContent-Type: application/jsonis missing.
- The error
-
Content-LenghtandContent-Typefix: !75170 (merged)- S3 don't return the
Content-Lengthon aheadrequest (https://gitlab.com/gitlab-org/gitlab/blob/master/app/services/import/gitlab_projects/create_project_from_remote_file_service.rb#L70); - S3 don't use
application/gzipfor atar.gz(https://gitlab.com/gitlab-org/gitlab/blob/master/app/services/import/gitlab_projects/create_project_from_remote_file_service.rb#L7), instead it usesapplication/x-tar;
- S3 don't return the
Edited by Kassio Borges