Skip to content

fix: clean up stale PR state when repo removed or PR merged to non-acceptable branch#399

Closed
jamesrayammons wants to merge 1 commit intoentrius:testfrom
jamesrayammons:fix/stale-pr-state-cleanup
Closed

fix: clean up stale PR state when repo removed or PR merged to non-acceptable branch#399
jamesrayammons wants to merge 1 commit intoentrius:testfrom
jamesrayammons:fix/stale-pr-state-cleanup

Conversation

@jamesrayammons
Copy link
Copy Markdown

When a repository is removed from master_repositories.json, existing PR records in the database kept their old pr_state indefinitely. Similarly, PRs merged to non-acceptable branches were skipped during evaluation, leaving stale OPEN state in the DB.

Two cleanup mechanisms added:

  • Scenario 1 (repo removed): DELETE PR records for repos no longer in master_repositories
  • Scenario 2 (non-acceptable branch): UPDATE pr_state for skipped merged PRs to reflect actual GitHub state

Related Issues

Fixes #398

Type of Change

  • Bug fix

Testing

  • Tests added/updated
  • Manually tested

10 tests added in tests/validator/test_stale_pr_cleanup.py:

  • 6 SQL logic tests (SQLite in-memory) covering both scenarios
  • 4 Python unit tests (mocked DB) for Repository methods

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

@jamesrayammons jamesrayammons force-pushed the fix/stale-pr-state-cleanup branch from fa7eb6c to ccf0cad Compare April 13, 2026 19:25
@anderdc anderdc force-pushed the fix/stale-pr-state-cleanup branch from ccf0cad to 618cf36 Compare April 14, 2026 04:19
…ceptable branch

When a repository is removed from master_repositories.json, existing PR
records in the database kept their old pr_state indefinitely. Similarly,
PRs merged to non-acceptable branches were skipped during evaluation,
leaving stale OPEN state in the DB.

Two cleanup mechanisms added:
- DELETE PR records for repos no longer in master_repositories
- UPDATE pr_state for skipped merged PRs to reflect actual GitHub state

Fixes entrius#398
@jamesrayammons jamesrayammons force-pushed the fix/stale-pr-state-cleanup branch from 618cf36 to ecfbea7 Compare April 14, 2026 05:14
@jamesrayammons
Copy link
Copy Markdown
Author

@anderdc @LandynDev could you review this PR?

@anderdc anderdc closed this Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale PR state in database when repository is removed from tracking

2 participants