Skip to content

Commit 060a698

Browse files
committed
fix: skip PR review comment collection when pull requests are disabled
Builds on augurlabs#3783 (check_prs_enabled infrastructure). Applies the same disabled-PR check to collect_pull_request_review_comments, which hits the repos/{owner}/{repo}/pulls/comments endpoint — this also returns 404 when PRs are disabled and had no prior handling. Also migrates the URL construction to use GithubDataAccess.endpoint_url() following the pattern established in retrieve_all_pr_data.
1 parent 9b267a9 commit 060a698

File tree

1 file changed

+11
-6
lines changed
  • augur/tasks/github/pull_requests

1 file changed

+11
-6
lines changed

augur/tasks/github/pull_requests/tasks.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,23 +227,31 @@ def collect_pull_request_review_comments(repo_git: str, full_collection: bool) -
227227
"""
228228
owner, repo = get_owner_repo(repo_git)
229229

230-
review_msg_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/comments"
231-
232230
logger = logging.getLogger(collect_pull_request_review_comments.__name__)
233231
logger.debug(f"Collecting pull request review comments for {owner}/{repo}")
234232

233+
key_auth = GithubRandomKeyAuth(logger)
234+
github_data_access = GithubDataAccess(key_auth, logger)
235+
236+
if not github_data_access.check_prs_enabled(owner, repo):
237+
logger.info(f"{owner}/{repo}: Pull requests appear to be disabled for this repo. Skipping review comment collection.")
238+
return
239+
235240
repo_id = get_repo_by_repo_git(repo_git).repo_id
236241

242+
search_args = {}
237243
if not full_collection:
238244
last_collected_date = get_secondary_data_last_collected(repo_id)
239245

240246
if last_collected_date:
241247
# Subtract 2 days to ensure all data is collected
242248
core_data_last_collected = (last_collected_date - timedelta(days=2)).replace(tzinfo=timezone.utc)
243-
review_msg_url += f"?since={core_data_last_collected.isoformat()}"
249+
search_args["since"] = core_data_last_collected.isoformat()
244250
else:
245251
logger.warning(f"core_data_last_collected is NULL for recollection on repo: {repo_git}")
246252

253+
review_msg_url = github_data_access.endpoint_url(f"repos/{owner}/{repo}/pulls/comments", search_args or None)
254+
247255
pr_reviews = get_pull_request_reviews_by_repo_id(repo_id)
248256

249257
# Build mapping once: github pr_review_src_id -> augur pr_review_id
@@ -257,9 +265,6 @@ def collect_pull_request_review_comments(repo_git: str, full_collection: bool) -
257265
tool_version = "2.0"
258266
data_source = "Github API"
259267

260-
key_auth = GithubRandomKeyAuth(logger)
261-
github_data_access = GithubDataAccess(key_auth, logger)
262-
263268
pr_review_comment_batch_size = get_batch_size()
264269

265270
# Batch processing: accumulate comments until batch size reached, then flush

0 commit comments

Comments
 (0)