Skip to content

Unable to import project into nested group using just `path' field via API

Summary

The project import API docs specify the following fields:

attr desc required
path Name and path for new project. yes
namespace The ID or path of the namespace to import the project to. Defaults to the current user’s namespace. no

From my reading, I'd expect the following payloads to be equivalent:

A:

{ "path": "aa/bb/project" }

B:

{ "path": "project", "namespace": "aa/bb" }

However, payload A fails with an error.

Steps to reproduce

  1. Export a project as project.tar.gz and save it in your working directory.

  2. Create the following group structure on your instance:

    aa
    └bb
    cc
  3. Import the project into the top level group:

    curl --request POST --header "PRIVATE-TOKEN: $GITLAB_DEV_TOKEN" \
      --form "path=cc/myproj" \
      --form "[email protected]" "http://gdk.test:3000/api/v4/projects/import"
    
    # {"message":"Project namespace path must not start or end with a special character and must not contain consecutive special characters."}
  4. Import the project into the nested group:

    curl --request POST --header "PRIVATE-TOKEN: $GITLAB_DEV_TOKEN" \
      --form "path=aa/bb/myproj" \
      --form "[email protected]" "http://gdk.test:3000/api/v4/projects/import"
    
    # {"message":"Project namespace path must not start or end with a special character and must not contain consecutive special characters."}
  5. Attempt the top-level import using the separate argument:

    curl --request POST --header "PRIVATE-TOKEN: $GITLAB_DEV_TOKEN" \
      --form "path=myproj" \
      --form "namespace=cc" \
      --form "[email protected]" "http://gdk.test:3000/api/v4/projects/import"
    
    # {"id":37,"name":"myproj","name_with_namespace":"cc / myproj","path":"myproj","path_with_namespace":"cc/myproj", ...}
  6. Delete the previously imported project and attempt the nested import using the separate argument:

    curl --request POST --header "PRIVATE-TOKEN: $GITLAB_DEV_TOKEN" \
      --form "path=myproj" \
      --form "namespace=aa/bb" \
      --form "[email protected]" "http://gdk.test:3000/api/v4/projects/import"
    
    # {"id":38,"name":"myproj","name_with_namespace":"aa / bb / myproj","path":"myproj","path_with_namespace":"aa/bb/myproj", ...}

What is the current bug behavior?

Only the imports where path and namespace are provided separately succeed.

What is the expected correct behavior?

All imports succeed.

Proposal

Starting point: #432805 (comment 1747806202)

@m_frankiewicz @wortschi Can I confirm that my expectations are correct, here?

Edited by Martin Wortschack
OSZAR »