From d4e8f618cef730f45246011a00351a759da6e246 Mon Sep 17 00:00:00 2001 From: Tal Date: Tue, 17 Jun 2025 08:34:07 +0300 Subject: [PATCH] Update pr_agent/servers/github_action_runner.py Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com> --- pr_agent/servers/github_action_runner.py | 38 +++++++++++++----------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/pr_agent/servers/github_action_runner.py b/pr_agent/servers/github_action_runner.py index 014268f2..45a9bc93 100644 --- a/pr_agent/servers/github_action_runner.py +++ b/pr_agent/servers/github_action_runner.py @@ -83,27 +83,29 @@ async def run_action(): get_logger().info(f"github action: failed to apply repo settings: {e}") # Append the response language in the extra instructions - response_language = get_settings().config.get('response_language', 'en-us') - if response_language.lower() != 'en-us': - get_logger().info(f'User has set the response language to: {response_language}') + try: + response_language = get_settings().config.get('response_language', 'en-us') + if response_language.lower() != 'en-us': + get_logger().info(f'User has set the response language to: {response_language}') - lang_instruction_text = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial." - separator_text = "\n======\n\nIn addition, " + lang_instruction_text = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial." + separator_text = "\n======\n\nIn addition, " - for key in get_settings(): - setting = get_settings().get(key) - if isinstance(setting, DynaBox): - if key.lower() in ['pr_description', 'pr_code_suggestions', 'pr_reviewer']: - if hasattr(setting, 'extra_instructions'): - extra_instructions = setting.extra_instructions - - if lang_instruction_text not in str(extra_instructions): - updated_instructions = ( - str(extra_instructions) + separator_text + lang_instruction_text - if extra_instructions else lang_instruction_text - ) - setting.extra_instructions = updated_instructions + for key in get_settings(): + setting = get_settings().get(key) + if isinstance(setting, DynaBox): + if key.lower() in ['pr_description', 'pr_code_suggestions', 'pr_reviewer']: + if hasattr(setting, 'extra_instructions'): + extra_instructions = setting.extra_instructions + if lang_instruction_text not in str(extra_instructions): + updated_instructions = ( + str(extra_instructions) + separator_text + lang_instruction_text + if extra_instructions else lang_instruction_text + ) + setting.extra_instructions = updated_instructions + except Exception as e: + get_logger().info(f"github action: failed to apply language-specific instructions: {e}") # Handle pull request opened event if GITHUB_EVENT_NAME == "pull_request" or GITHUB_EVENT_NAME == "pull_request_target": action = event_payload.get("action")