Commit 896a7c1d authored by Vasilii Iakliushin's avatar Vasilii Iakliushin

Return a 422 error for Changelog::Error exception

* Contributes to https://gitlab.com/gitlab-org/gitlab/-/issues/351520
* Sentry error: https://sentry.gitlab.net/gitlab/gitlabcom/issues/3190373

Changelog: fixed
parent 011f0a42
...@@ -248,6 +248,8 @@ module API ...@@ -248,6 +248,8 @@ module API
changelog = service.execute(commit_to_changelog: false) changelog = service.execute(commit_to_changelog: false)
present changelog, with: Entities::Changelog present changelog, with: Entities::Changelog
rescue Gitlab::Changelog::Error => ex
render_api_error!("Failed to generate the changelog: #{ex.message}", 422)
end end
desc 'Generates a changelog section for a release and commits it in a changelog file' do desc 'Generates a changelog section for a release and commits it in a changelog file' do
......
...@@ -783,6 +783,13 @@ RSpec.describe API::Repositories do ...@@ -783,6 +783,13 @@ RSpec.describe API::Repositories do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['notes']).to be_present expect(json_response['notes']).to be_present
end end
context 'when previous tag version does not exist' do
it_behaves_like '422 response' do
let(:request) { get api("/projects/#{project.id}/repository/changelog", user), params: { version: 'v0.0.0' } }
let(:message) { 'Failed to generate the changelog: The commit start range is unspecified, and no previous tag could be found to use instead' }
end
end
end end
describe 'POST /projects/:id/repository/changelog' do describe 'POST /projects/:id/repository/changelog' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment