Skip to content

fix(ci): prevent stale PR closer from incorrectly closing new PRs#18069

Merged
bdmorgan merged 1 commit intomainfrom
fix/stale-pr-closer-maintainer-detection
Feb 1, 2026
Merged

fix(ci): prevent stale PR closer from incorrectly closing new PRs#18069
bdmorgan merged 1 commit intomainfrom
fix/stale-pr-closer-maintainer-detection

Conversation

@bdmorgan
Copy link
Collaborator

@bdmorgan bdmorgan commented Feb 1, 2026

Summary

Fixes a bug in the stale PR closer workflow where new PRs could be incorrectly closed due to lastActivity being initialized to epoch and a lack of a minimum age check.

Details

  • Added a check to skip PRs created less than 30 days ago.
  • Initialized lastActivity to pr.created_at instead of new Date(0).
  • Enhanced logging for maintainer team fetching and activity fetching failures to provide better diagnostics.
  • Ensures maintainer PRs aren't immediately closed if team fetch fails.

How to Validate

  1. Inspect the logic in .github/workflows/gemini-scheduled-stale-pr-closer.yml.
  2. Verified that thirtyDaysAgo is correctly calculated.
  3. The logic if (prCreatedAt > thirtyDaysAgo) continue; correctly skips young PRs.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run

   This fixes a bug where PRs from maintainers (or any PR) could be
   immediately closed as stale even when just opened. The root causes:

   1. If team member fetch failed silently, maintainerLogins was empty
   2. lastActivity was initialized to epoch (1970), so any PR without
      detected maintainer activity appeared 50+ years old
   3. No minimum age check - PRs created today could be marked stale

   Changes:
   - Add explicit check to skip PRs created < 30 days ago from staleness
   - Initialize lastActivity to PR creation date instead of epoch
   - Improve logging for team fetch success/failure with details
   - Add error logging for reviews/comments fetch failures

   Fixes issue where PR #18035 from a maintainer was incorrectly closed.
@bdmorgan bdmorgan requested a review from a team as a code owner February 1, 2026 19:58
@gemini-code-assist
Copy link
Contributor

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@github-actions
Copy link

github-actions bot commented Feb 1, 2026

Size Change: -2 B (0%)

Total Size: 23.6 MB

ℹ️ View Unchanged
Filename Size Change
./bundle/gemini.js 23.6 MB -2 B (0%)
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB 0 B
./bundle/sandbox-macos-permissive-open.sb 890 B 0 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB 0 B
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB 0 B
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB 0 B
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB 0 B

compressed-size-action

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Feb 1, 2026
@bdmorgan bdmorgan merged commit 707b3e8 into main Feb 1, 2026
29 checks passed
@bdmorgan bdmorgan deleted the fix/stale-pr-closer-maintainer-detection branch February 1, 2026 20:13
yuvrajangadsingh pushed a commit to yuvrajangadsingh/gemini-cli that referenced this pull request Feb 4, 2026
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant