Skip to content

OAuth: update the affected member directly on organization member events - #13242

Draft
ericholscher wants to merge 1 commit into
mainfrom
claude/gh-app-member-events
Draft

OAuth: update the affected member directly on organization member events#13242
ericholscher wants to merge 1 commit into
mainfrom
claude/gh-app-member-events

Conversation

@ericholscher

@ericholscher ericholscher commented Aug 18, 2026

Copy link
Copy Markdown
Member

Bulk membership changes in a GitHub organization send one organization webhook event per member, and each event triggered a full sync of the installation — at least one API request per repository. Large installations exceed GitHub's per-installation hourly rate limit this way: a recent bulk change produced ~600 events in a few minutes, every sync failing with RateLimitExceededException.

Since the event names the affected member, we now update exactly that member instead of re-syncing the whole installation. Removed members have their relations deleted using the membership.user payload — zero API requests, which also works while rate limited. Added members are first checked for a connected account (most org members don't have one — zero requests); when they do, we check their permission on repositories linked to a project only, one request each, and the rest of their access is populated on their next sign-in (existing behavior). Cost now scales with the event rather than the org, so no debouncing or caching is needed.

#13243 builds on this branch to make the remaining full syncs cheaper.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LVjkPjH3EDEQmtywJvDVau

Bulk membership changes send one organization event per member, and
each event triggered a full sync of the installation, costing at least
one API request per repository. Large installations exceed GitHub's
per-installation rate limit this way.

Since the event includes the affected member, we now update that
member only. Removed members have their access revoked directly from
the database, without querying the API. Added members with an account
connected have their access checked against repositories linked to a
project (one request each); the rest of their access is synced when
they sign in.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LVjkPjH3EDEQmtywJvDVau
@ericholscher
ericholscher force-pushed the claude/gh-app-member-events branch from 60fb149 to 80962a8 Compare August 18, 2026 22:37
@ericholscher ericholscher changed the title OAuth: handle organization member events without a sync per event OAuth: update the affected member directly on organization member events Aug 18, 2026
ericholscher added a commit that referenced this pull request Aug 19, 2026
A rate-limited GitHub API request [fails with a
403](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api),
and `update_or_create_repositories()` treats any 403 as if we lost
access to the repository — deleting the `RemoteRepository` and silently
disconnecting its projects. Large installations are currently hitting
the rate limit during webhook-triggered syncs, so this is actively
waiting to happen.

A rate limit now aborts the operation without deleting anything, and
without making further doomed requests. The task still fails visibly —
no retries. PyGithub raises `RateLimitExceededException` (a
`GithubException` subclass) for both [primary and secondary rate
limits](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#about-secondary-rate-limits),
so catching it before the generic 403/404 handling covers both.

Reducing the API usage that triggers the rate limits is handled
separately in #13241, #13242, and #13243. Likely related to #13101,
since build statuses and PR comments share the same per-installation
budget.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01LVjkPjH3EDEQmtywJvDVau

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants