Commit 549b5c3a authored by Stan Hu's avatar Stan Hu

Merge branch 'generate-human-readable-message-for-duplicate-dotenv-variables' into 'master'

Generate human readable message on duplicate dotenv variables

See merge request gitlab-org/gitlab!75861
parents 6c464495 eda1c64e
......@@ -14,7 +14,7 @@ module Ci
Ci::JobVariable.bulk_insert!(variables)
success
rescue SizeLimitError, ParserError, ActiveRecord::RecordInvalid => error
rescue SizeLimitError, ParserError, ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique => error
Gitlab::ErrorTracking.track_exception(error, job_id: artifact.job_id)
error(error.message, :bad_request)
end
......
......@@ -23,6 +23,20 @@ RSpec.describe Ci::ParseDotenvArtifactService do
hash_including('key' => 'KEY2', 'value' => 'VAR2'))
end
context 'when dotenv variables are conflicting against manual variables' do
before do
create(:ci_job_variable, job: build, key: 'KEY1')
end
it 'returns an error message that there is a duplicate variable' do
subject
expect(subject[:status]).to eq(:error)
expect(subject[:message]).to include("Key (key, job_id)=(KEY1, #{build.id}) already exists.")
expect(subject[:http_status]).to eq(:bad_request)
end
end
context 'when parse error happens' do
before do
allow(service).to receive(:scan_line!) { raise described_class::ParserError, 'Invalid Format' }
......
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