Commit 7eceb3a8 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch...

Merge branch '344085-terraform-state-provider-reports-a-500-error-when-the-lineage-or-version-does-not-match' into 'master'

Return a client error for duplicate Terraform state serials

See merge request gitlab-org/gitlab!75809
parents 2487542e 924a228c
......@@ -11,6 +11,13 @@ module API
default_format :json
rescue_from(
::ActiveRecord::RecordNotUnique,
::PG::UniqueViolation
) do |e|
render_api_error!(e.message, 422)
end
before do
authenticate!
authorize! :read_terraform_state, user_project
......
......@@ -152,6 +152,16 @@ RSpec.describe API::Terraform::State do
expect(response).to have_gitlab_http_status(:ok)
expect(Gitlab::Json.parse(response.body)).to be_empty
end
context 'when serial already exists' do
let(:params) { { 'instance': 'example-instance', 'serial': state.latest_version.version } }
it 'returns unprocessable entity' do
request
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
end
context 'without body' 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