fix: route sync PRs/calendar through Octokit install client - #864
fix: route sync PRs/calendar through Octokit install client#864ionfwsrijan wants to merge 2 commits into
Conversation
|
@ionfwsrijan is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Soumya-codr @codersogs-code Please review this |
jakharmonika364
left a comment
There was a problem hiding this comment.
Traced the fail-closed change through both call sites - syncGitHubStats's existing try/catch absorbs the new throw cleanly, and adding fetchAndBackfillPRs to the Inngest job matches what #859 asked for, so no unhandled-exception concerns.
One gap: the new retry/backoff logic in getInstallOctokit's request hook has no test coverage - could you add a case for a 429 succeeding on retry, and one for MAX_ATTEMPTS exhaustion? Also the throw new Error('Exhausted retry attempts...') after the loop is dead code since every loop path already returns or throws.
|
@jakharmonika364 I've made the changes |
Fix: Route Sync PRs/Calendar Through the Octokit Install Client (#859)
Problem
The GitHub sync code called the REST Search API and GraphQL with a raw installation token via
global.fetch, bypassing the Octokit client (src/lib/github/app.ts) that centralizes token acquisition, rate-budget tracking, and secondary rate-limit backoff. The user-triggered sync action and the backgroundgithub-stats-syncInngest job also carried two divergent, duplicated PR-backfill implementations that could drift.Changes
src/app/actions/github-sync-helpers.ts:fetchMergedCount,fetchContributionCalendar, andfetchContributionStreaknow take anOctokitand useoctokit.search.issuesAndPullRequests/octokit.graphqlinstead of rawfetch. Added a single sharedfetchAndBackfillPRs(up to 100 PRs, upsert intopull_requests) that fails closed — no install id or a GitHub API error throws rather than silently degrading the sync.src/app/actions/github-sync.ts: now re-exports the backfill + types from the helpers, so the action and the Inngest job share one implementation.src/inngest/functions/github-stats-sync.tsandsrc/inngest/functions/audit-run.ts: same Octokit wiring.src/lib/github/app.ts:getInstallOctokitis the single entry point (tokens, rate-budget recording, backoff).getInstallOctokitinstead ofglobal.fetch, with new expectations for fail-closed install id and propagated API failures.Impact
All GitHub traffic flows through the Octokit install client with centralized rate handling, and sync behavior can no longer diverge between the action and the background job.
Closes #859