Skip to content

Commit 031d197

Browse files
committed
Retry issue comments with public API on auth failure
1 parent f71a2f5 commit 031d197

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

blog/ingestors/github_issues.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,24 @@ def ingest(repo: str, token: str | None, config_dir: Path) -> tuple[list[dict],
378378
for issue in visible_issues:
379379
num = issue["number"]
380380
print(f" Processing issue #{num}: {issue['title']}")
381-
raw_comments = _fetch_comments(repo, num, headers)
381+
try:
382+
raw_comments = _fetch_comments(repo, num, headers)
383+
except requests.RequestException as exc:
384+
if "Authorization" not in headers:
385+
raise
386+
status = (
387+
exc.response.status_code
388+
if isinstance(exc, requests.HTTPError) and exc.response is not None
389+
else "unknown"
390+
)
391+
msg = (
392+
f"Warning: authenticated GitHub comments fetch failed for issue #{num}"
393+
f" (HTTP {status}). Retrying with the public API."
394+
)
395+
print(f" {msg}", file=sys.stderr)
396+
warnings.append(msg)
397+
headers = _github_headers(None)
398+
raw_comments = _fetch_comments(repo, num, headers)
382399
post = _process_issue(issue, raw_comments, blocked, fork_owners, repo, repo_name, headers)
383400
posts.append(post)
384401

0 commit comments

Comments
 (0)