Skip to content

Create Release API returns a 500 error for invalid tag

Summary

Create Release API returns a 500 error when providing an invalid Tag name

Steps to reproduce

Try to create a Release via the API with an invalid tag_name value such as --ref

See job https://gitlab.com/gitlab-org/gitlab-releaser/-/jobs/431128566

Also reproducible using the GDK

Example Project

GitLab releaser https://gitlab.com/gitlab-org/gitlab-releaser/-/jobs/431128566

What is the current bug behavior?

A 500 - Internal Server Error status code is returned instead of a user error e.g. 400 - Bad Request

What is the expected correct behavior?

Return a user error such as 400 - Bad Request or similar

Maybe update the documentation with valid characters that can be used https://docs.gitlab.com/ee/api/releases/#create-a-release

Relevant logs and/or screenshots

curl --header "PRIVATE-TOKEN:[MASKED]" "$GITLAB_SERVER/api/v4/projects/21/releases" \
--data '{"id":"21","name":"release new","description":"wow this is great","tag_name":"--ref", "ref":"123"}' \
-X POST --header 'Content-Type: application/json' -i

HTTP/1.1 500 Internal Server Error
Cache-Control: no-cache
Content-Length: 30
Content-Type: application/json
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Request-Id: U2D36mvlHO7
X-Runtime: 0.148143
Date: Mon, 10 Feb 2020 03:22:20 GMT

{"message":"Tag name invalid"}

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:env:info)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

(If you can, link to the line of code that might be responsible for the problem)

/cc @jmeshell @sean_carroll

Edited by Jackie Porter