Gitlab Fork 404 Target Namespace Not Found

I am using the python gitlab API to fork a project into the same use account but renamed as a new new project. Previously this was working. I don’t think I introduced a regression into my codebase.

What I am trying to accomplish:

https://gitlab.com/user-namespace/project-to-clone ----> https://gitlab.com/user-namespace/path-to-renamed-project

Here is a CURL reproducing the error:

curl -d="namespace=user-namespace&path=path-to-renamed-project&name=project-to-clone" -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "PRIVATE-TOKEN: <TOKEN>" "https://gitlab.com/api/v4/projects/<PRJ_ID>/fork"

The response:

{"message":"404 Target Namespace Not Found"}

Here is the python gitlab api code which reproduces the same bug:

import json
import gitlab

token = '<token>'
repo_path = 'user-namespace/project-to-clone'
namespace = 'user-namespace'
path = 'path-to-renamed-project'
gl = gitlab.Gitlab('https://gitlab.com/', oauth_token=token)
gl.auth()
try:
  project = gl.projects.get(repo_path)
except gitlab.exceptions.GitlabGetError as e:
  print(json.loads(e.response_body))

try:
  clone = project.forks.create({'namespace': namespace, 'path': path, 'name': path})
except gitlab.exceptions.GitlabCreateError as e:
  print(json.loads(e.response_body))
1 Like