Commit 8182dcdf authored by Yorick Peterse's avatar Yorick Peterse

Use HTTP 422 for changelog API errors

In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/53890 it was
brought up that an HTTP 500 error is a very generic error, and that an
HTTP 422 error code is better suited for the changelog API.

This fixes https://gitlab.com/gitlab-org/gitlab/-/issues/321676
parent a116779f
......@@ -227,7 +227,7 @@ module API
service.execute
status(200)
rescue Gitlab::Changelog::Error => ex
render_api_error!("Failed to generate the changelog: #{ex.message}", 500)
render_api_error!("Failed to generate the changelog: #{ex.message}", 422)
end
end
end
......
......@@ -687,7 +687,7 @@ RSpec.describe API::Repositories do
}
)
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['message']).to eq('Failed to generate the changelog: oops')
end
end
......
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