@@ -285,25 +285,41 @@ export async function triageSecurityFinding(options: {
285285 correlationId,
286286 findingId : finding . id ,
287287 status : result . status ,
288+ model,
288289 } ) ;
289- captureException ( new Error ( `Triage API error: ${ result . status } ` ) , {
290- tags : { operation : 'triageSecurityFinding' } ,
291- extra : {
292- findingId : finding . id ,
293- status : result . status ,
294- error : result . error ,
295- correlationId,
296- } ,
297- } ) ;
290+
291+ // Provider-side errors we expect when users pick models that are
292+ // delisted (404), rate-limited (408/429), or when the provider is
293+ // down (5xx). These are not actionable on our side.
294+ // All other statuses (e.g. 400/401/403) may indicate bugs in our
295+ // request or auth path and should still reach Sentry.
296+ const isProviderError =
297+ result . status === 404 ||
298+ result . status === 408 ||
299+ result . status === 429 ||
300+ result . status >= 500 ;
301+
302+ if ( ! isProviderError ) {
303+ captureException ( new Error ( `Triage API error: ${ result . status } ` ) , {
304+ tags : { operation : 'triageSecurityFinding' } ,
305+ extra : {
306+ findingId : finding . id ,
307+ status : result . status ,
308+ error : result . error ,
309+ model,
310+ correlationId,
311+ } ,
312+ } ) ;
313+ }
298314
299315 span . setAttribute ( 'security_agent.status' , 'error' ) ;
300316 span . setAttribute ( 'security_agent.is_fallback' , true ) ;
301317
302318 addBreadcrumb ( {
303319 category : 'security-agent.triage' ,
304- message : ' Triage fallback used' ,
320+ message : ` Triage fallback used (model= ${ model } , status= ${ result . status } )` ,
305321 level : 'warning' ,
306- data : { correlationId, findingId : finding . id , isFallback : true } ,
322+ data : { correlationId, findingId : finding . id , model , isFallback : true } ,
307323 } ) ;
308324
309325 return createFallbackTriage ( `API error: ${ result . status } ` ) ;
0 commit comments