[BUG]: Complete Analysis can silently skip repositories when the PAT has access to private repos

Open Beginner friendly
#394 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@g-k-s-03 is already working on this.

Since Oct 22, 2026.

  • #397 by @g-k-s-03 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github, javascript
Domain
api, backend

Research direction

Start with fetchRepos in src/services/github.js and the call in src/context/AppContext.jsx; the issue includes a reproduction using a stubbed fetch that returns 100 repositories, then 50. First read the repository fetching tests and check how the project defines Complete Analysis scope. Done when the test confirms the intended repositories are all fetched and the existing tests pass.

Written by the indexing model from the issue text.

Description

bug
Bug Description
Summary

With a Personal Access Token configured, fetchRepos decides how many pages to request based on the organization's public repository count. If the token can also see private repositories, GitHub returns more repositories than that count, and the remaining pages are never requested. Those repositories are silently missing from the analysis.

Root cause

In src/services/github.js:

export async function fetchRepos(org, repoCount, pat) {
  const all = []
  const maxPages = pat ? Math.ceil(repoCount / 100) : 5
  for (let page = 1; page <= maxPages; page++) {
    const url = `https://api.github.com/orgs/${org}/repos?per_page=100&page=${page}&sort=updated`
    const data = await fetchWithCache(url, pat)
    all.push(...data)
    if (data.length < 100) break
  }
  return all
}

src/context/AppContext.jsx calls it as:

fetchRepos(org.login, org.public_repos, pat)

The request URL does not set a type parameter, so for an authenticated token the /orgs/{org}/repos endpoint returns every repository the token can access, including private ones. The page limit, however, is calculated from org.public_repos only. When the token can see more repositories than public_repos, the loop reaches maxPages and stops, even though GitHub still has more full pages to return.

For example, with public_repos = 50 and 150 repositories visible to the token, maxPages is 1, so only the first 100 repositories are fetched and the remaining 50 are dropped.

Impact
  • Total Repos, the Repositories page, and the analytics built on them can be based on an incomplete list, with no indication that data is missing.
  • Private repositories can also be included in the results, while the "Learn More" panel describes Complete Analysis as covering all public repositories.

This only affects users whose token has access to private repositories in the analyzed organization.

Possible fixes

Either of these would resolve it, depending on the intended scope of Complete Analysis:

  1. Fetch public repositories only, by adding type=public to the request. This matches the "Learn More" description, and public_repos then becomes an accurate page count.
  2. Keep paginating until GitHub returns a page with fewer than 100 items, instead of deriving the limit from public_repos (with a reasonable safety cap).

I'd be happy to work on this once the preferred approach is confirmed.

Steps to Reproduce

The issue can be reproduced with a unit test against the current main branch, by stubbing fetch to serve 150 repositories across two pages while public_repos is 50:

// fetch is stubbed to return 100 repos for page 1 and 50 repos for page 2
const result = await fetchRepos('some-org', 50, 'pat-token')
expect(result).toHaveLength(150)

Result:
AssertionError: expected 100 to be 150

Only the first page is requested, because maxPages = Math.ceil(50 / 100) = 1.

Real-world reproduction:

  1. Add a PAT in Settings that has access to private repositories of an organization.
  2. Explore that organization.
  3. Compare the number of repositories shown with the number visible to the token on GitHub. If the token can see more repositories than the organization's public count, some are missing.

Expected: all repositories in scope are fetched.

Actual: fetching stops after ceil(public_repos / 100) pages, and the remaining repositories are skipped.

Logs and Screenshots

Test output from npx vitest run:

AssertionError: expected 100 to be 150 // Object.is equality

- Expected
+ Received

- 150
+ 100
Environment Details
  • Branch: upstream main (as of 21 October 2026)
  • Reproduced with: npx vitest run
  • Files: src/services/github.js (fetchRepos), src/context/AppContext.jsx
Impact

Critical - Application is unusable

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Dominant language
JavaScript
Stars
53
Forks
187
Avg merge
18m
Merged PRs (30d)
2

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/OrgExplorer

All issues in AOSSIE-Org/OrgExplorer

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.