Skip to content
Snippets Groups Projects
Unverified Commit d93d7cb6 authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak :speech_balloon: Committed by GitLab
Browse files

Merge branch 'updated-vr-suggestion-error-message' into 'master'

Updated error message when VR MR suggestions can’t be created

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/168986



Merged-by: default avatarMikołaj Wawrzyniak <mwawrzyniak@gitlab.com>
Approved-by: default avatarSubashis Chakraborty <schakraborty@gitlab.com>
Approved-by: default avatarMikołaj Wawrzyniak <mwawrzyniak@gitlab.com>
Reviewed-by: default avatarSubashis Chakraborty <schakraborty@gitlab.com>
Co-authored-by: default avatarDarby Frey <dfrey@gitlab.com>
parents 4e4c8131 5fcddce4
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -11,7 +11,8 @@ class ResolveVulnerability < Gitlab::Llm::Completions::Base
'AI resolution to a merge request.'
MR_LINK_ERROR = 'An error occurred while attempting to link the MR to the vulnerability.'
RESPONSE_FAILURE_ERROR = 'Response from AI is unreadable. Please try again.'
MERGE_REQUEST_SUGGESTION_ERROR = 'An error occurred while attempting to create the merge request suggestion.'
MERGE_REQUEST_SUGGESTION_ERROR = 'Resolution target could not be found in the merge request, ' \
'unable to create suggestion.'
START_CODE = "<fixed_code>\n"
END_CODE = "</fixed_code>"
START_ANALYSIS = "<analysis>\n"
Loading
Loading
Loading
Loading
@@ -116,6 +116,8 @@ def latest_merge_request_diff
strong_memoize_attr :latest_merge_request_diff
 
def position
raise TargetLineNotFound if suggestion_target_line.nil?
{
position_type: "text",
old_path: @path,
Loading
Loading
Loading
Loading
@@ -25,8 +25,9 @@
end
 
let_it_be(:diff) { File.read(File.join(fixtures_folder, 'input.diff')) }
let(:mr_suggestion) { described_class.new(diff, filepath, merge_request) }
 
subject(:attributes_hash) { described_class.new(diff, filepath, merge_request).note_attributes_hash }
subject(:attributes_hash) { mr_suggestion.note_attributes_hash }
 
before do
merge_request.reload
Loading
Loading
@@ -61,5 +62,12 @@
expect { attributes_hash }.to raise_exception(described_class::TargetLineNotFound)
end
end
context 'when suggestion_target_line is nil' do
it 'raises an error' do
expect(mr_suggestion).to receive(:suggestion_target_line).and_return(nil)
expect { attributes_hash }.to raise_exception(described_class::TargetLineNotFound)
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment