Skip to content
Snippets Groups Projects
Unverified Commit 5fcddce4 authored by Darby Frey's avatar Darby Frey Committed by GitLab
Browse files

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

Messaging is now more specific when errors occur when attempting to resolve a vulnerability with AI in a merge request.

Changelog: changed
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/168986
EE: true
parent aaa7711e
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