Skip to content

fix: keep block checks in budget and stop repo-name squats - #194

Merged
jamesconwaydev merged 3 commits into
mainfrom
fix-review-wave4
Nov 6, 2026
Merged

jamesconwaydev merged 3 commits into
mainfrom
fix-review-wave4

Conversation

@jamesconwaydev

@jamesconwaydev jamesconwaydev commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Two fixes from the final review: one keeps the Likes sync inside the API budget, and one stops a name squat from taking over an entry.

Block checks were one API call per Liker

Every hour, sync_likes called GET /orgs/devstreamhq/blocks/{login} for each cached trusted reactor. With a few thousand Likers that alone uses up the installation's hourly budget, and then Likes freeze.

Now the org's block list gets read once per run (blocked_logins, which pages through per_page=100) and folded into the exclusions. An excluded login already reads as BLOCKED and skips the cache, so a new block still takes effect on the very next run. Submit and reports use the same set. If the token can't read the list, the run still fails closed: a 404 on the listing raises (paginate(..., must_exist=True)) instead of reading as nobody blocked.

A squatter's repo could inherit an entry (#36)

Entries were keyed only by owner/name. Say an owner renames or deletes their account. Someone registers the old login and creates a repo with the same name, and the health check carries the listing, its Likes and the link over to the stranger's repo.

  • Every entry now stores repo_id, GitHub's numeric ID, which never changes and is never reused. Submissions and seeds record it from the repo response.
  • validate_data.py and data/schema.json require it: a positive integer, never null. The validator also rejects two entries with the same repo_id.
  • All 454 existing entries are backfilled. I ran a one-off gh api repos/{owner}/{name} over the file. Every entry resolved, aquasecurity/trivy included, and none of the names redirect.
  • If the health check finds a different ID at the listed name, the entry gets a removal notice and a needs-review issue ("A different repo now answers to …"). The entry itself isn't updated. A real rename keeps its ID, so it still just follows the new name. An entry with no repo_id gets a warning in the log, and the run carries on.
  • The hourly Likes sync now reads databaseId along with the card. If it doesn't match repo_id, the sync keeps the last card (the same way it handles a repo hidden by an IP allow list), logs a warning and flags the entry, so the stranger's stars and avatar never show up and the entry can't trend. Until the entry comes off the list it still links to that name, and the review issue says so.

Known gap: the review issue is deduped against open issues only. If a maintainer closes it and the mismatch is still there, next week's run opens a new one.

Tests

python3.12 -m unittest discover -s scripts -t .: 546 pass. Block list: one listing, lowercased, 404 and 5xx still fail, and cache hits make no calls, and a 404 on the listing raises. Validator: repo_id is required, must be positive and can't repeat. Likes sync: a mismatched ID keeps the old card and flags the entry, for live and flagged entries alike. Health check: a mismatch gives a notice plus one review issue with no rename, and a matching ID follows the rename. npx prettier --check passes on both data files.

Not in this PR: letting rot sleep through rate-limit resets or shard its run, and batching rot's reads through GraphQL (I5 b and c). Both change how rot is scheduled or how it fetches, so they need their own PR.

sync_likes looked up /orgs/devstreamhq/blocks/{login} for every cached
trusted reactor, every hour. With a few thousand Likers that alone
spends the installation's hourly budget. The block list is now read
once per run and folded into the exclusions, which already read as
BLOCKED and skip the cache.
Entries were keyed by owner/name only. If an owner renamed or deleted
their account, someone could register the old login, create a repo
with the same name, and the health check would carry the listing and
its Likes over to it.

Every entry now stores GitHub's numeric repo_id, which never changes
and is never reused. Submissions and seeds record it, validate_data
and schema.json require it, and all 454 existing entries are
backfilled. When the health check finds a different ID at the listed
name, the entry gets a removal notice and a needs-review issue
instead of being updated. A rename keeps its ID, so it still just
follows the new name.

Closes #36
The health check gave a replaced repo a removal notice, but the hourly
Likes sync still read stars, avatar and language by name, so the
stranger's repo showed on the card and could trend for a week.
sync_likes now compares GitHub's databaseId to the entry's repo_id,
keeps the last card on a mismatch and flags the entry.

Also: blocked_logins read a 404 on the block listing as nobody
blocked (paginate now takes must_exist), validate_data rejects a
duplicate repo_id, rot warns on an entry with no repo_id, and the
review issue text no longer claims more than the code does.
@jamesconwaydev
jamesconwaydev merged commit 04e7eb7 into main Nov 6, 2026
8 checks passed
@jamesconwaydev
jamesconwaydev deleted the fix-review-wave4 branch November 6, 2026 14:52
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.

1 participant