Skip to content

Feature/pat full analysis#89

Merged
rahul-vyas-dev merged 5 commits into
AOSSIE-Org:mainfrom
Ri1tik:feature/pat-full-analysis
Jun 25, 2026
Merged

Feature/pat full analysis#89
rahul-vyas-dev merged 5 commits into
AOSSIE-Org:mainfrom
Ri1tik:feature/pat-full-analysis

Conversation

@Ri1tik

@Ri1tik Ri1tik commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Addressed Issues:

Fixes #

Screenshots/Recordings:

WITH_PAT || WITHOUT_PAT
Screenshot 2026-06-23 011618
Screenshot 2026-06-23 011742
Screenshot 2026-06-24 211039
Screenshot 2026-06-24 211230

Additional Notes:

  • Unauthenticated users continue to use the existing API-efficient limits.
  • When a PAT is available, OrgExplorer performs significantly more complete repository, contributor, and governance analysis.
  • This change improves analysis coverage while maintaining backward compatibility.
  • Extremely large organizations may still require future optimizations due to GitHub API rate-limit constraints.

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Audits can now include a larger set of repositories when an access token is available.
  • Bug Fixes

    • Improved repository, contributor, and issue loading for larger organizations with more reliable pagination.
    • Contributor and issue lists now aggregate results across multiple pages instead of stopping after a limited number.

@github-actions github-actions Bot added no-issue-linked PR has no linked issue frontend Frontend changes javascript JavaScript/TypeScript changes size/S 11-50 lines changed labels Jun 24, 2026
@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

fetchRepos now uses a repository count for page limits when PAT is present. fetchContributors and fetchIssues now collect multiple pages. AppContext passes org.public_repos and switches between capped and full repository lists based on PAT availability.

Changes

PAT-aware pagination improvements

Layer / File(s) Summary
Service pagination updates
src/services/github.js
fetchRepos accepts repoCount and derives maxPages from it when PAT is present, while fetchContributors and fetchIssues now loop through per_page=100 pages until a short page is returned.
PAT-aware repo selection
src/context/AppContext.jsx
explore passes org.public_repos into fetchRepos and chooses contributor repos with a PAT-aware conditional; runAudit uses all repositories with PAT and keeps the 15-repo cap otherwise.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Typescript Lang

Suggested reviewers

  • bhavik-mangla

Possibly related PRs

  • AOSSIE-Org/OrgExplorer#80: Both PRs modify src/services/github.js’s fetchRepos; that PR changes URL formatting, while this one changes the function signature and pagination behavior.

Poem

🐇 Hop hop, the pages now flow,
With PAT in paw, the totals grow.
Repos, issues, contributors too,
Each page is fetched right through and through.
The rabbit grins: "More data to know!"

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: enabling fuller analysis when a PAT is provided.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added external-contributor External contributor size/S 11-50 lines changed and removed size/S 11-50 lines changed labels Jun 24, 2026
@Ri1tik Ri1tik added the gsoc GSoC students label Jun 24, 2026
@github-actions github-actions Bot added size/S 11-50 lines changed and removed size/S 11-50 lines changed labels Jun 24, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/context/AppContext.jsx (1)

76-83: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Do not publish a silently partial full-org audit.

With PAT, this can issue at least one request per repo, plus pagination. Large orgs can exceed the PAT rate budget, and Promise.allSettled then swallows RATE_LIMIT rejections while setIssuesData(map) still marks the audit complete.

Add a request budget/cap or stop on RATE_LIMIT and surface the partial-audit state before expanding to all repos.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/context/AppContext.jsx` around lines 76 - 83, The batched fetch in
AppContext’s repo loop can silently complete a partial org audit because
Promise.allSettled ignores RATE_LIMIT failures while setIssuesData(map) still
finalizes the result. Update the fetch flow around the repos batching logic to
enforce a request budget/cap or stop processing as soon as fetchIssues reports
RATE_LIMIT, and surface an explicit partial-audit state instead of marking
completion. Use the existing symbols fetchIssues, Promise.allSettled, and
setIssuesData in AppContext.jsx to locate and adjust the control flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/context/AppContext.jsx`:
- Around line 39-45: In AppContext’s contributor-loading loop, the PAT branch
for computing top repositories drops the empty-array fallback, so a failed org
can leave reposPerOrg[org.login] unset and make top.map crash. Update the top
assignment in the validOrgs loop to always fall back to an empty array for both
PAT and non-PAT cases, then keep the existing sort/slice logic before
Promise.allSettled.

---

Outside diff comments:
In `@src/context/AppContext.jsx`:
- Around line 76-83: The batched fetch in AppContext’s repo loop can silently
complete a partial org audit because Promise.allSettled ignores RATE_LIMIT
failures while setIssuesData(map) still finalizes the result. Update the fetch
flow around the repos batching logic to enforce a request budget/cap or stop
processing as soon as fetchIssues reports RATE_LIMIT, and surface an explicit
partial-audit state instead of marking completion. Use the existing symbols
fetchIssues, Promise.allSettled, and setIssuesData in AppContext.jsx to locate
and adjust the control flow.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1f0c39f7-01eb-4d20-8048-7711b8d2d4fa

📥 Commits

Reviewing files that changed from the base of the PR and between 46c5c95 and d04608a.

📒 Files selected for processing (2)
  • src/context/AppContext.jsx
  • src/services/github.js

Comment thread src/context/AppContext.jsx
@github-actions github-actions Bot added size/S 11-50 lines changed and removed size/S 11-50 lines changed labels Jun 24, 2026
@github-actions github-actions Bot added size/S 11-50 lines changed and removed size/S 11-50 lines changed labels Jun 24, 2026
@PrithvijitBose

Copy link
Copy Markdown

So now are we able to fetch more repos?

I just searched Microsoft and it showed me 500 repos and now with this feature we are able to fetch all of the repos of Microsoft or just some portion of it?

@Ri1tik

Ri1tik commented Jun 25, 2026

Copy link
Copy Markdown
Contributor Author

So now are we able to fetch more repos?

I just searched Microsoft and it showed me 500 repos and now with this feature we are able to fetch all of the repos of Microsoft or just some portion of it?

Yes. Before this PR, repo fetching was limited to 500 repos regardless of organization size. With a PAT, the fetch is now dynamic and continues until all repo pages have been retrieved. For organizations like Microsoft, We can analyze all accessible repositories instead of only the first 500. The previous cap is still preserved for unauthenticated users to remain within GitHub's rate limits.

@github-actions

Copy link
Copy Markdown

⚠️ This PR has merge conflicts.

Please resolve the merge conflicts before review.

Your PR will only be reviewed by a maintainer after all conflicts have been resolved.

📺 Watch this video to understand why conflicts occur and how to resolve them:
https://www.youtube.com/watch?v=Sqsz1-o7nXk

@github-actions github-actions Bot added size/S 11-50 lines changed and removed PR has merge conflicts size/S 11-50 lines changed labels Jun 25, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/context/AppContext.jsx (1)

117-118: 🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

PAT branch audits the full repo list, contradicting the UI and risking rate-limit exhaustion.

With a PAT, repos becomes the entire model.allRepos. For a large org (e.g. Microsoft ~8,122 repos) runAudit then issues fetchIssues for every repo in batches of 5, and each fetchIssues now paginates over all issue pages — potentially tens of thousands of requests that can blow through the 5,000 req/hr PAT limit and stall the audit.

It also contradicts the user-facing copy in src/pages/AnalyticsPage.jsx ("Fetching issue and PR history for top 15 repositories...") and the repoNames = ['All', ...model.allRepos.slice(0, 12)...] selector, so most fetched repos aren't even selectable.

Consider capping the PAT branch to a sane bound (and/or surfacing progress), instead of unbounded model.allRepos.

⚙️ Example bound
-    const repos = pat? model.allRepos : model.allRepos.slice(0, 15)
+    const repos = model.allRepos.slice(0, pat ? 50 : 15)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/context/AppContext.jsx` around lines 117 - 118, The PAT path in
AppContext’s repo selection is using the full model.allRepos list, which can
trigger unbounded audits. Update the repos assignment in AppContext.jsx so the
pat branch also applies a reasonable cap (matching the UI’s top-repos behavior,
e.g. the same limit used for non-PAT or selector copy), and ensure runAudit only
receives that bounded list instead of all repos.
src/services/github.js (1)

89-120: 🩺 Stability & Availability | 🟡 Minor

Verify safety bounds in fetchContributors and fetchIssues pagination logic.

While callers wrap these functions in Promise.allSettled (preventing global crashes), fetchContributors and fetchIssues rely solely on page size to terminate the loop (for(;;) ... if(data.length < 100) break).

  • Missing safety cap: Unlike fetchRepos, these functions lack a maxPages limit. While GitHub API usually returns an empty array on the final page, relying solely on this behavior risks infinite loops or excessive requests if the API returns partial data unexpectedly.
  • Error handling: fetchWithCache throws on 403/404 rather than returning an empty list. Ensure the Promise.allSettled usage in the caller is sufficient to handle result.reason for partial failures, or consider a tighter loop bound.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/services/github.js` around lines 89 - 120, `fetchContributors` and
`fetchIssues` currently use unbounded pagination loops based only on
`data.length < 100`, so add a safety cap similar to `fetchRepos` by introducing
a `maxPages` limit in each function and stopping when that limit is reached.
Keep the pagination behavior in `fetchContributors` and `fetchIssues` tied to
`fetchWithCache`, but ensure any thrown 403/404 errors remain handled by the
existing `Promise.allSettled` caller by surfacing failures normally rather than
looping indefinitely.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/context/AppContext.jsx`:
- Around line 117-118: The PAT path in AppContext’s repo selection is using the
full model.allRepos list, which can trigger unbounded audits. Update the repos
assignment in AppContext.jsx so the pat branch also applies a reasonable cap
(matching the UI’s top-repos behavior, e.g. the same limit used for non-PAT or
selector copy), and ensure runAudit only receives that bounded list instead of
all repos.

In `@src/services/github.js`:
- Around line 89-120: `fetchContributors` and `fetchIssues` currently use
unbounded pagination loops based only on `data.length < 100`, so add a safety
cap similar to `fetchRepos` by introducing a `maxPages` limit in each function
and stopping when that limit is reached. Keep the pagination behavior in
`fetchContributors` and `fetchIssues` tied to `fetchWithCache`, but ensure any
thrown 403/404 errors remain handled by the existing `Promise.allSettled` caller
by surfacing failures normally rather than looping indefinitely.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2c3ad2c2-ab32-4ba6-b10f-c12170f57db1

📥 Commits

Reviewing files that changed from the base of the PR and between d04608a and 55fc6f7.

📒 Files selected for processing (2)
  • src/context/AppContext.jsx
  • src/services/github.js

@rahul-vyas-dev rahul-vyas-dev merged commit f936776 into AOSSIE-Org:main Jun 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor External contributor frontend Frontend changes gsoc GSoC students javascript JavaScript/TypeScript changes no-issue-linked PR has no linked issue size/S 11-50 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants