Skip to content

Forking project failure message does not explain why the operation failed

Summary

If I attempt to fork a project using an already existing name, the fork operation fails with the generic error message An error occurred while forking the project. Please try again.:

The error message should indicate why the failure occurred.

Steps to reproduce

  1. Create a new personal project called container-scanning, for example: https://gitlab.com/adamcohen/container-scanning
  2. Attempt to fork an existing project also called container-scanning, for example: https://gitlab.com/gitlab-org/security-products/analyzers/container-scanning/-/forks/new

What is the current bug behavior?

The following error message is output: An error occurred while forking the project. Please try again.

What is the expected correct behavior?

The error message should explain why the fork failed to be created, for example:

An error occurred while forking the project: a project already exists with the name "container-scanning". Please use a different name for the forked project.

Possible fixes

When forking a project using the API, the correct error message is returned:

curl --request POST --header "PRIVATE-TOKEN: <my-token>" --header "Content-Type: application/json" \
      https://gitlab.com/api/v4/projects/24673064/fork
{"message":{"project_namespace.name":["has already been taken"],"name":["has already been taken"],"path":["has already been taken"]}}%

It seems we just need to propagate this same error message in the UI.