Import file from object storage fails if URL length exceeds 512
Summary
Currently the character limit for the Import/Export URL used by the Import a file from a remote object storage feature is set to 512
. Pre-signed URLs can easily exceed this limit and will cause the request to fail.
Steps to reproduce
- Create an API request using the
/projects/remote-import
endpoint similar to this one with theurl
attribute character length > 512.
curl --request POST \
--header "PRIVATE-TOKEN: <your_access_token>" \
--header "Content-Type: application/json" \
--url "https://gitlab.example.com/api/v4/projects/remote-import" \
--data '{"url":"https://url_length_exceed_512","path":"remote-project"}'
Example Project
What is the current bug behavior?
The API request will fail and raise this error message.
{"message":"PG::CheckViolation: ERROR: new row for relation \"import_export_uploads\" violates check constraint \"check_58f0d37481\"\nDETAIL: Failing row contains (1398482, 2022-02-08 08:24:06.033916+00, 33508437, null, null, null, <generated pre-signed url>...).\n"}
What is the expected correct behavior?
The API request should succeed.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Possible fixes
It's possible to increase this limit by updating the constraint for the remote_import_url text attribute.
CREATE TABLE import_export_uploads (
id integer NOT NULL,
updated_at timestamp with time zone NOT NULL,
project_id integer,
import_file text,
export_file text,
group_id bigint,
remote_import_url text,
CONSTRAINT check_58f0d37481 CHECK ((char_length(remote_import_url) <= 512))
);
Related Case
Edited by Kent Japhet Ballon