@@ -160,6 +160,23 @@ def main():
160160 error_analysis = extract_build_errors (prefix_build_output )
161161 print ("\n ❌ Build is broken ❌ -- No fix attempted." )
162162 print (f"Build output:\n { error_analysis } " )
163+
164+ # Notify the Remediation service about the failed build
165+ remediation_notified = contrast_api .notify_remediation_failed (
166+ remediation_id = remediation_id ,
167+ failure_category = "INITIAL_BUILD_FAILURE" ,
168+ contrast_host = config .CONTRAST_HOST ,
169+ contrast_org_id = config .CONTRAST_ORG_ID ,
170+ contrast_app_id = config .CONTRAST_APP_ID ,
171+ contrast_auth_key = config .CONTRAST_AUTHORIZATION_KEY ,
172+ contrast_api_key = config .CONTRAST_API_KEY
173+ )
174+
175+ if remediation_notified :
176+ print (f"Successfully notified Remediation service about failed build for remediation { remediation_id } ." , flush = True )
177+ else :
178+ print (f"Warning: Failed to notify Remediation service about failed build for remediation { remediation_id } ." , flush = True )
179+
163180 git_handler .cleanup_branch (new_branch_name )
164181 sys .exit (1 ) # Exit if the build is broken, no point in proceeding
165182
@@ -221,10 +238,34 @@ def main():
221238 # Skip PR creation if QA was run and the build is failing
222239 # or if the QA agent encountered an error (detected by checking qa_summary_log entries)
223240 if (used_build_command and not build_success ) or any (s .startswith ("Error during QA agent execution:" ) for s in qa_summary_log ):
241+ failure_category = ""
242+
224243 if any (s .startswith ("Error during QA agent execution:" ) for s in qa_summary_log ):
225244 print ("\n --- Skipping PR creation as QA Agent encountered an error ---" )
245+ failure_category = "QA_AGENT_FAILURE"
226246 else :
227247 print ("\n --- Skipping PR creation as QA Agent failed to fix build issues ---" )
248+ # Check if we've exhausted all retry attempts
249+ if len (qa_summary_log ) >= max_qa_attempts_setting :
250+ failure_category = "EXCEEDED_QA_ATTEMPTS"
251+
252+ # Notify the Remediation service about the failed remediation if we have a failure category
253+ if failure_category :
254+ remediation_notified = contrast_api .notify_remediation_failed (
255+ remediation_id = remediation_id ,
256+ failure_category = failure_category ,
257+ contrast_host = config .CONTRAST_HOST ,
258+ contrast_org_id = config .CONTRAST_ORG_ID ,
259+ contrast_app_id = config .CONTRAST_APP_ID ,
260+ contrast_auth_key = config .CONTRAST_AUTHORIZATION_KEY ,
261+ contrast_api_key = config .CONTRAST_API_KEY
262+ )
263+
264+ if remediation_notified :
265+ print (f"Successfully notified Remediation service about { failure_category } for remediation { remediation_id } ." , flush = True )
266+ else :
267+ print (f"Warning: Failed to notify Remediation service about { failure_category } for remediation { remediation_id } ." , flush = True )
268+
228269 git_handler .cleanup_branch (new_branch_name )
229270 continue # Move to the next vulnerability
230271
0 commit comments