Skip to content

[Feature request] Include tag name when returning error for duplicate tag

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Proposal

When API call it made to protect a tag which is already protected, GitLab returns the message : Name has already been taken. However, when running automations like GitLabForm, it's difficult to know at which tag the automation failed due to existing protected tag.

For example, the following API call marks the tag test as protected and executes without any issues:

> curl --request POST \
  --header "PRIVATE-TOKEN: $PJ_TAG" \
  --header "Content-Type: application/json" \
  --data '{"name": "test", "create_access_level": "40"}' \
  "https://gitlab.com/api/v4/projects/XYZ/protected_tags"
{"name":"test","create_access_levels":[{"id":XYZ,"access_level":40,"access_level_description":"Maintainers","deploy_key_id":null,"user_id":null,"group_id":null}]}%

However, if I run the same API call again, I get the error Name has already been taken :

> curl --request POST \
  --header "PRIVATE-TOKEN: $PJ_TAG" \
  --header "Content-Type: application/json" \
  --data '{"name": "test", "create_access_level": "40"}' \
  "https://gitlab.com/api/v4/projects/XYZ/protected_tags"
{"message":["Name has already been taken"]}%

Looking at the GitLab source code and this is an expected behaviour. However, it would be really helpful if we can include the entity (in this case the tag name) which is failing the API call.

Customer request (Zendesk ticket) : https://gitlab.zendesk.com/agent/tickets/568428 (Internal URL)

Edited by 🤖 GitLab Bot 🤖