File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,18 +190,22 @@ def run(options)
190190 $stderr. print " #{ index } /#{ total } warnings processed\r "
191191 end
192192
193- if set_analysis
194- warning . llm_analysis = llm . analyze_warning ( warning )
193+ begin
194+ if set_analysis
195+ warning . llm_analysis = llm . analyze_warning ( warning )
195196
196- if disclaimer
197- warning . llm_analysis << "\n \n " << disclaimer
198- end
199- else
200- warning . message << "\n \n " << llm . analyze_warning ( warning )
197+ if disclaimer
198+ warning . llm_analysis << "\n \n " << disclaimer
199+ end
200+ else
201+ warning . message << "\n \n " << llm . analyze_warning ( warning )
201202
202- if disclaimer
203- warning . message << "\n \n " << disclaimer
203+ if disclaimer
204+ warning . message << "\n \n " << disclaimer
205+ end
204206 end
207+ rescue RubyLLM ::Error => e
208+ Brakeman . notify "Failed to analyze warning (#{ warning . fingerprint } ): #{ e } "
205209 end
206210 end
207211
Original file line number Diff line number Diff line change @@ -157,4 +157,20 @@ def test_disclaimer_in_json
157157 chat_mock . verify
158158 response_mock . verify
159159 end
160+
161+ def test_error_during_analysis
162+ bm_llm = Brakeman ::LLM . new ( model : 'test_model' , provider : 'test_provider' )
163+ analysis = 'Extended warning description'
164+ tracker = nil
165+
166+ chat_mock = -> ( _ ) { raise RubyLLM ::Error }
167+
168+ bm_llm . llm . stub ( :chat , chat_mock ) do
169+ tracker = Brakeman . run ( llm : { llm : bm_llm } , app_path : rails_app , output_format : :json )
170+ end
171+
172+ tracker . warnings . each do |w |
173+ assert_nil w . llm_analysis
174+ end
175+ end
160176end
You can’t perform that action at this time.
0 commit comments