Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#394 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 4 ngày

@g-k-s-03 đang làm issue này rồi.

Từ ngày 22/10/2026.

  • #397 của @g-k-s-03 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
github, javascript
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu với fetchRepos trong src/services/github.js và lời gọi trong src/context/AppContext.jsx; issue có phần tái hiện lỗi bằng fetch giả lập, trả về 100 repository rồi 50. Trước tiên, đọc các bài kiểm tra việc lấy repository và kiểm tra cách dự án xác định phạm vi Complete Analysis. Hoàn tất khi bài kiểm tra xác nhận tất cả repository dự kiến đều được lấy và các bài kiểm tra hiện có đều đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
JavaScript
Star
45
Fork
148
Merge trung bình
5 ngày 14 giờ
Pull request đã merge (30 ngày)
30

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AOSSIE-Org/OrgExplorer

Tất cả issue của AOSSIE-Org/OrgExplorer

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.