Delete Protected tags - New v15.0 feature not working when using REST API

Greetings!

I found this MR Allow delete of protected tags if user has authority (!85527) · Merge requests · GitLab.org / GitLab · GitLab that grants the ability for a project Maintainer to delete a protected tag. In the description of the ticket, it states that project owners and maintainers have the option to delete protected tags. In the web UI, it prompts the user with a confirmation dialogue. It gives no examples of how this changed affected the API, but it does list the API as a resource that can be used to delete protected tags. It lists the milestone as 15.0.

I’ve recently updated my Omnibus package to 15.0.5 (GET /version returns "version":"15.0.5","revision":"f415ebdb978"}). Yet if I try to delete a protected tag, I get the error message “Protected tags cannot be deleted”. I checked the REST API docs and it doesn’t say anything other than the project ID and the tag name can be used with DELETE (no “force” flag or anything).

To test it out, I created a test tag in my project, set it to protected, then used curl -X DELETE --header "PRIVATE-TOKEN: $TOKEN" https://gitlab.mydomain.com/api/v4/projects/1234/repository/tags/test-protected where test-protected is the new tag I made. The error returned was {"message":"Protected tags cannot be deleted."}

Does anyone know how this is supposed to work with the API or know why it’s not working for me?

Or perhaps I’m reading the MR wrong and it hasn’t released yet? Or isn’t a feature for self-managed?

Thank you!

1 Like

I am wondering the same. The documentation says:

You can manually delete protected tags with the GitLab API, or the GitLab user interface.

But when looking at the protected tags API, it does not exist an option to delete protected tags, the only one is to unprotect a tag:

Unprotects the given protected tag or wildcard protected tag.

DELETE /projects/:id/protected_tags/:name

I have confirmed that this is the case, i.e. it only removes the tag protection rule, not the tag itself.

So either the documentation is wrong, or they have not listed all available APIs in the protected tag API documentation.

1 Like

The document is incorrect I believe, I had a similar use case where I wanted to delete and recreate a protected tag. Compared with other working api calls and I found that we can delete a protected tag by slightly modifying the url in curl.

I took a reference from @dgoo2308 's comment on this issue token access with api returns "404 Project Not Found" on an internal project or public project with member only access to repository or private project (#29022) · Issues · GitLab.org / GitLab FOSS · GitLab

curl --request DELETE -H "PRIVATE-TOKEN: Access Token Here" "https://gitlab.example.com/api/v4/projects/"project_id"/repository/tags/"tag_name"