Skip to content

Commit 31ec1ad

Browse files
committed
fix(reviewer-bot): infer pr observer context correctly
1 parent 8c895bd commit 31ec1ad

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

.github/reviewer-bot-tests/test_reviewer_bot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,6 @@ def test_pr_comment_observer_routes_through_reviewer_bot_payload_builder():
13341334

13351335

13361336
def test_build_pr_comment_observer_payload_marks_trusted_direct_same_repo_as_observer_noop(monkeypatch):
1337-
monkeypatch.setenv("IS_PULL_REQUEST", "true")
13381337
monkeypatch.setenv("GITHUB_REPOSITORY", "rustfoundation/safety-critical-rust-coding-guidelines")
13391338
monkeypatch.setenv("COMMENT_USER_TYPE", "User")
13401339
monkeypatch.setenv("COMMENT_AUTHOR", "PLeVasseur")

scripts/reviewer_bot_lib/comment_routing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ def classify_pr_comment_processing_target(bot, issue_number: int) -> str:
125125
actor_class = classify_issue_comment_actor()
126126
if actor_class in {"bot_account", "github_app_or_other_automation"} or _is_self_comment(bot, os.environ.get("COMMENT_AUTHOR", "")):
127127
return "safe_noop"
128-
if not _is_pr_event():
129-
return "issue_direct"
130128
pull_request = _fetch_pr_metadata(bot, issue_number)
131129
head_repo = pull_request.get("head", {}).get("repo", {})
132130
head_full_name = head_repo.get("full_name") if isinstance(head_repo, dict) else None
@@ -145,6 +143,8 @@ def classify_pr_comment_processing_target(bot, issue_number: int) -> str:
145143

146144

147145
def route_issue_comment_trust(bot, issue_number: int) -> str:
146+
if not _is_pr_event():
147+
return "issue_direct"
148148
target = classify_pr_comment_processing_target(bot, issue_number)
149149
if target != "pr_trusted_direct":
150150
return target

0 commit comments

Comments
 (0)