diff --git a/pr_agent/servers/github_app.py b/pr_agent/servers/github_app.py index 80a673d7..9c0a5cee 100644 --- a/pr_agent/servers/github_app.py +++ b/pr_agent/servers/github_app.py @@ -118,15 +118,9 @@ async def handle_new_pr_opened(body: Dict[str, Any], event: str, sender: str, sender_id: str, - sender_type: str, action: str, log_context: Dict[str, Any], agent: PRAgent): - # logic to ignore PRs opened by bot - if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False) and sender_type == "Bot": - get_logger().info(f"Ignoring PR from '{sender=}' due to github_app.ignore_bot_pr setting") - return {} - title = body.get("pull_request", {}).get("title", "") # logic to ignore PRs with specific titles (e.g. "[Auto] ...") @@ -261,6 +255,11 @@ async def handle_request(body: Dict[str, Any], event: str): agent = PRAgent() log_context, sender, sender_id, sender_type = get_log_context(body, event, action, build_number) + # logic to ignore PRs opened by bot + if get_settings().get("GITHUB_APP.IGNORE_BOT_PR", False) and sender_type == "Bot": + get_logger().info(f"Ignoring PR from '{sender=}' due to github_app.ignore_bot_pr setting") + return {} + # handle comments on PRs if action == 'created': get_logger().debug(f'Request body', artifact=body, event=event) @@ -268,7 +267,7 @@ async def handle_request(body: Dict[str, Any], event: str): # handle new PRs elif event == 'pull_request' and action != 'synchronize' and action != 'closed': get_logger().debug(f'Request body', artifact=body, event=event) - await handle_new_pr_opened(body, event, sender, sender_id, sender_type, action, log_context, agent) + await handle_new_pr_opened(body, event, sender, sender_id, action, log_context, agent) # handle pull_request event with synchronize action - "push trigger" for new commits elif event == 'pull_request' and action == 'synchronize': get_logger().debug(f'Request body', artifact=body, event=event)