File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 2121import json
2222import sys
2323from typing import Optional
24+ from enum import Enum
2425import config
2526from utils import debug_print
2627
28+ # Define failure categories as an enum to ensure consistency
29+ class FailureCategory (Enum ):
30+ INITIAL_BUILD_FAILURE = "INITIAL_BUILD_FAILURE"
31+ EXCEEDED_QA_ATTEMPTS = "EXCEEDED_QA_ATTEMPTS"
32+ QA_AGENT_FAILURE = "QA_AGENT_FAILURE"
33+ GIT_COMMAND_FAILURE = "GIT_COMMAND_FAILURE"
34+ AGENT_FAILURE = "AGENT_FAILURE"
35+ GENERATE_PR_FAILURE = "GENERATE_PR_FAILURE"
36+ HANDLE_PR_MERGE_FAILURE = "HANDLE_PR_MERGE_FAILURE"
37+ HANDLE_PR_CLOSE_FAILURE = "HANDLE_PR_CLOSE_FAILURE"
38+ GENERAL_FAILURE = "GENERAL_FAILURE"
39+
2740def normalize_host (host : str ) -> str :
2841 """Remove any protocol prefix from host to prevent double prefixing when constructing URLs."""
2942 return host .replace ('https://' , '' ).replace ('http://' , '' )
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ def main():
164164 # Notify the Remediation service about the failed build
165165 remediation_notified = contrast_api .notify_remediation_failed (
166166 remediation_id = remediation_id ,
167- failure_category = " INITIAL_BUILD_FAILURE" ,
167+ failure_category = contrast_api . FailureCategory . INITIAL_BUILD_FAILURE . value ,
168168 contrast_host = config .CONTRAST_HOST ,
169169 contrast_org_id = config .CONTRAST_ORG_ID ,
170170 contrast_app_id = config .CONTRAST_APP_ID ,
@@ -242,12 +242,12 @@ def main():
242242
243243 if any (s .startswith ("Error during QA agent execution:" ) for s in qa_summary_log ):
244244 print ("\n --- Skipping PR creation as QA Agent encountered an error ---" )
245- failure_category = " QA_AGENT_FAILURE"
245+ failure_category = contrast_api . FailureCategory . QA_AGENT_FAILURE . value
246246 else :
247247 print ("\n --- Skipping PR creation as QA Agent failed to fix build issues ---" )
248248 # Check if we've exhausted all retry attempts
249249 if len (qa_summary_log ) >= max_qa_attempts_setting :
250- failure_category = " EXCEEDED_QA_ATTEMPTS"
250+ failure_category = contrast_api . FailureCategory . EXCEEDED_QA_ATTEMPTS . value
251251
252252 # Notify the Remediation service about the failed remediation if we have a failure category
253253 if failure_category :
You can’t perform that action at this time.
0 commit comments