Skip to content

Unable to create a project via the API with path and import_url parameters

Summary

Using the API endpoint POST /projects fails with a 400: Reserved Name error when path and import_url parameters are specified.

Steps to reproduce

Retrieve an oauth2 token and try:

curl -is -X POST -H "Authorization: Bearer <OAUTH2_TOKEN>" -H "Content-Type: application/json" -d '{"path":"testRepo-Put-clone","import_url":"https://github.com/bkicia2/KEEP_test_small_repo"}' https://gitlab.com/api/v4/projects

Or retrieve a personal access token and try:

curl -is -X POST -H "PRIVATE-TOKEN: <PAT>" -H "Content-Type: application/json" -d '{"path":"testRepo-Put-clone","import_url":"https://github.com/bkicia2/KEEP_test_small_repo"}' https://gitlab.com/api/v4/projects

**Same behavior with /api/v3/projects

Example Project

What is the current bug behavior?

The CURL request above returns this error:

400: {"message":{"path":["testRepo-Put-clone is a reserved name"],"base":["Unable to save project. Error: Path testRepo-Put-clone is a reserved name"],"limit_reached":[]}}

What is the expected correct behavior?

The CURL request above returns a 201 response with the new project information (or a relevant error).

Additional debugging information

After the API call failed, I tried creating this project from the GitLab UI to see if "testRepo-Put-clone" truly was a reserved name. I was successful, so I deleted the project and tried again with the same name and import url and again was successful. I also tried a bunch of different API combinations and figured out that the POST request is successful if name and import_url parameters are provided, and if just the path is provided. The only issue is with the path and import_url combination.

Relevant logs and/or screenshots

Output of checks

This bug happens when using the GitLab.com v3 and v4 APIs.

Results of GitLab environment info

N/A

Results of GitLab application Check

N/A

Possible fixes

Edited by Brianna Wegryn