Fix bugs in auto-close PR triage scripts

- close_low_quality_prs.py: Treat author_association API lookup failures
  as internal (fail-safe) so transient errors don't cause internal
  contributors' PRs to be auto-closed.
- triage_with_llm.py: Update summary heading from 'Would post comment:'
  to 'Posted comment:' since this branch only runs after the comment
  has already been posted.

Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
Cursor Agent 2026-05-17 17:04:07 +00:00
parent 401433374d
commit edddf0c179
No known key found for this signature in database
2 changed files with 5 additions and 2 deletions

View file

@ -116,7 +116,10 @@ def is_external_pr_author(pr: dict, repo: str | None) -> bool:
if login.endswith("[bot]") or login in {"dependabot", "github-actions"}:
return False
association = fetch_pr_author_association(pr["number"], repo)
if association in INTERNAL_AUTHOR_ASSOCIATIONS:
# Fail-safe: if the API lookup failed (empty string), treat the author as
# internal so we don't auto-close their PR. Auto-close is destructive, so
# an unknown association should never make a PR eligible for closing.
if not association or association in INTERNAL_AUTHOR_ASSOCIATIONS:
return False
return True

View file

@ -520,7 +520,7 @@ def render_summary(result: dict) -> str:
comment = result.get("comment")
if comment:
lines.append("")
lines.append("### Would post comment:")
lines.append("### Posted comment:")
lines.append("")
lines.append("> " + comment.replace("\n", "\n> "))
return "\n".join(lines)