Skip to content

Increase remote import URL character length limit from 512 to 2048

What does this MR do and why?

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. If pre-signed URLs are used then it can easily exceed this limit.

This MR aims to increase the remote_import_url under import_export_uploads table from 512 to 2048.

This was raised from this issue.

Migration Output

$ bundle exec rails db:migrate:up VERSION=20220321025720
== 20220321025720 AlterConstraintRemoteImportUrl: migrating ===================
-- transaction_open?()
   -> 0.0000s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE import_export_uploads\nDROP CONSTRAINT IF EXISTS check_58f0d37481\n")
   -> 0.0018s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0002s
-- transaction_open?()
   -> 0.0000s
-- execute("ALTER TABLE import_export_uploads\nADD CONSTRAINT check_58f0d37481\nCHECK ( char_length(remote_import_url) <= 2048 )\nNOT VALID;\n")
   -> 0.0033s
-- current_schema()
   -> 0.0003s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- execute("ALTER TABLE import_export_uploads VALIDATE CONSTRAINT check_58f0d37481;")
   -> 0.0014s
-- execute("RESET statement_timeout")
   -> 0.0005s
== 20220321025720 AlterConstraintRemoteImportUrl: migrated (0.0245s) ==========

$ bundle exec rails db:migrate:down VERSION=20220321025720
== 20220321025720 AlterConstraintRemoteImportUrl: reverting ===================
== 20220321025720 AlterConstraintRemoteImportUrl: reverted (0.0000s) ==========

Screenshots or screen recordings

N/A

How to set up and validate locally

  1. The migrations can be run locally via bundle exec rails db:migrate:up and bundle exec rails db:migrate:down.

Test Results

  1. I performed some basic tests around this API by using a URL that exceeds 512 character length.
curl --request POST \
>   --header "PRIVATE-TOKEN: <REDACTED>" \
>   --header "Content-Type: application/json" \
>   --url "http://localhost:3000/api/v4/projects/remote-import" \
>   --data '{"url":"https://<REDACTED>.s3.amazonaws.com/test.txt.txt?123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF","path":"remote-project"}'
{"message":"PG::CheckViolation: ERROR:  new row for relation \"import_export_uploads\" violates check constraint \"check_58f0d37481\"\nDETAIL:  Failing row contains (1, 2022-02-18 02:23:55.708108+00, 20, null, null, null, https://kentballon-test-bucket.s3.amazonaws.com/test.txt.txt?123...).\n"}
  1. After updating the limit from 512 to 2048 using db:migrate:up, I don't hit this error anymore.
curl --request POST \
>   --header "PRIVATE-TOKEN: <REDACTED>" \
>   --header "Content-Type: application/json" \
>   --url "http://localhost:3000/api/v4/projects/remote-import" \
>   --data '{"url":"https://<REDACTED>.s3.amazonaws.com/test.txt.txt?123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF123123ABCDEF","path":"remote-project"}'
{"id":21,"description":null,"name":"remote-project","name_with_namespace":"gdk_user_01 / remote-project","path":"remote-project","path_with_namespace":"gdk_user_01/remote-project","created_at":"2022-02-18T02:27:47.052Z","import_status":"scheduled","import_type":"gitlab_project","correlation_id":"01FW5AG7YWZQT9CMRDZTWXR741","failed_relations":[],"import_error":null,"stats":null}

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 Kent Japhet Ballon

Merge request reports

Loading