Skip to content

Enhance GitHub GraphQL Rate Limit Handling and Token Security#8273

Open
pisum-sativum wants to merge 5 commits into
JhaSourav07:mainfrom
pisum-sativum:fix-github-graphql-rate-limit
Open

Enhance GitHub GraphQL Rate Limit Handling and Token Security#8273
pisum-sativum wants to merge 5 commits into
JhaSourav07:mainfrom
pisum-sativum:fix-github-graphql-rate-limit

Conversation

@pisum-sativum

Copy link
Copy Markdown
Contributor

Description

Fixes #6239

This PR resolves critical issues related to GitHub GraphQL rate limit exhaustion and token exposure vulnerabilities.

Specific changes include:

  • Request Deduplication: Fixed a bug in lib/github.ts where request deduplication was bypassed for requests providing an options.signal. The background cache-populating fetch is now properly decoupled from individual request abort signals, preventing duplicate GraphQL calls for concurrent same-user requests.
  • Token Security & Log Sanitization: Safely caught network-level fetch errors (TypeError) and converted them into generic errors. This guarantees that Request objects, which contain the Authorization header with the Personal Access Token (PAT), are stripped and never logged to serverless dashboards or exposed to clients.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

No visual changes. This PR strictly improves backend API resilience, rate limit handling, and token security.

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

Copilot AI review requested due to automatic review settings July 22, 2026 17:24
@vercel

vercel Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

@pisum-sativum is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@retenta-bot

retenta-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

This pull request effectively resolves critical issues related to GitHub GraphQL rate limits and enhances token security. The changes made, such as request deduplication and error handling, are crucial for maintaining the integrity of our API interactions. It's worth noting that similar past decisions focused on improving user experience through visually themed error responses, which highlights our commitment to both functionality and user experience. Thank you for your contributions, and I look forward to your feedback!

@retenta-bot retenta-bot Bot changed the title Fix GitHub graphql rate limit Enhance GitHub GraphQL Rate Limit Handling and Token Security Jul 22, 2026
@pisum-sativum

Copy link
Copy Markdown
Contributor Author

@JhaSourav07 I have done the necessary changes kindly check and merge with appropriate labels.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves GitHub API resiliency by adjusting retry/abort behavior and contribution-request coalescing to reduce duplicated calls and avoid leaking sensitive request details, while also tweaking CI analytics paging and reordering the socials registry.

Changes:

  • Updates fetchWithRetry error/abort handling and adjusts contribution-fetch coalescing so abort signals don’t bypass deduplication.
  • Reduces CI Actions pagination depth for CI analytics fetches.
  • Sorts the socials registry alphabetically at module initialization.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
services/github/ci-analytics.ts Reduces Actions pagination (likely to lower API usage).
lib/github.ts Changes abort/error behavior in retry logic and contribution request coalescing for better dedup + safer error surfaces.
app/generator/data/socials.ts Sorts socials registry by display name (user-visible ordering change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/github.ts
Comment on lines 289 to +290
if (didThrow) {
if (options.signal?.aborted) throw fetchError;
if (options.signal?.aborted) throw new Error('AbortError');
Comment thread lib/github.ts
Comment on lines +957 to +962
return new Promise<ExtendedContributionData>((resolve, reject) => {
if (options.signal?.aborted) return reject(new Error('AbortError'));

const onAbort = () => reject(new Error('AbortError'));
options.signal?.addEventListener('abort', onAbort, { once: true });

Comment on lines +594 to +597
placeholder: 'e.g. https://huggingface.co/yourname',
},
] as Social[]
).sort((a, b) => a.name.localeCompare(b.name));
@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 3984.87 KB 3984.83 KB +0.04 KB (+0.00%)
Total CSS 331.41 KB 331.41 KB 0 B

@Aamod007 Aamod007 added level:advanced Complex contributions involving architecture, optimization, or significant feature work type:bug Something isn't working as expected type:security Security fixes, dependency updates, or hardening mentor:Aamod007 labels Jul 23, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a solid improvement to our GraphQL rate limit handling and request cancellation logic! The way you're handling \AbortError\ and coalescing requests is very robust.

However, similar to PR #8274, it looks like this branch contains unrelated changes that were accidentally committed. Specifically, the changes to \�pp/generator/data/socials.ts\ and \services/github/ci-analytics.ts\ do not belong in this PR.

To fix this, please revert the changes to those files using \git restore\ or \git checkout\ so that this PR is focused entirely on the GitHub API rate limit and token handling.

Looking forward to getting this merged once the branch is cleaned up!

Label Justification:

  • \level:advanced: Implementing complex request coalescing, abort controller logic, and rate-limit backoff across the API layer is an advanced task.
  • \ ype:bug\ & \ ype:security: Prevents token exhaustion and handles API edge cases securely.
  • \mentor:Aamod007: Assigned as required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:advanced Complex contributions involving architecture, optimization, or significant feature work mentor:Aamod007 type:bug Something isn't working as expected type:security Security fixes, dependency updates, or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix GitHub GraphQL Rate Limit + Token Security Vulnerability

3 participants