Skip to content

Commit

Permalink
Refactor is_bot_user function to improve actor type handling and lo…
Browse files Browse the repository at this point in the history
…gging
  • Loading branch information
mrT23 committed Nov 14, 2024
1 parent e0c1540 commit c934523
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pr_agent/servers/bitbucket_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ async def _perform_commands_bitbucket(commands_conf: str, agent: PRAgent, api_ur

def is_bot_user(data) -> bool:
try:
if data["data"]["actor"]["type"] != "user":
get_logger().info(f"BitBucket actor type is not 'user': {data['data']['actor']['type']}")
actor = data.get("data", {}).get("actor", {})
# allow actor type: user . if it's "AppUser" or "team" then it is a bot user
allowed_actor_types = {"user"}
if actor and actor["type"].lower() not in allowed_actor_types:
get_logger().info(f"BitBucket actor type is not 'user', skipping: {actor}")
return True
except Exception as e:
get_logger().error("Failed 'is_bot_user' logic: {e}")
get_logger().error(f"Failed 'is_bot_user' logic: {e}")
return False


Expand Down

0 comments on commit c934523

Please sign in to comment.