Skip to content

[Proposal] [API] When forking fails due to existing forked project, return the forked project

Right now, when forking a project A to project B via API fails due to B already exists, GitLab returns a HTTP 409 Conflict error. When it makes sense, this leaves the API user helpless, because there's no way to actually get that project B:

  • GET projects/A doesn't return the forked project(s), only a forks_count attribute. Not to mention that this requires access to A.
  • GET projects/:search isn't that advanced - you can only search name, namespace and the likes, not something like search={forked_from_project.id:A}
  • You can actually GET projects/owned and traverse down the list to see if there's a {forked_from_project.id:A} somewhere. This is very cumblesome however, and even impractical if the current authenticated user has hundreds of thousands of projects – for example, if he's a CI user.

So I'd propose GitLab, while still returning 409, to include the forked project B as the reponse's body.

Would be happy if there's actually a way to approach the desired result, and that I'm just being silly here.