[BUG]: `fetchWithCache` crashes with `SyntaxError: Unexpected end of JSON input` when encountering empty repositories (HTTP 204 No Content)
Maintainer thường phản hồi trong vòng 4 ngày
Đá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
- 76/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
Hướng nghiên cứu
Bắt đầu tại src/services/github.js, ở fetchWithCache và các hàm gọi fetchContributors, fetchRepos, fetchIssues và fetchPulls. Kiểm tra cách mã xử lý phản hồi thành công 204 No Content và liệu dữ liệu của hàm gọi có thể lặp qua được hay không; tái hiện bằng endpoint contributors của một repository trống. Hoàn tất khi việc khám phá một tổ chức có các repository trống kết thúc mà không gặp lỗi phân tích JSON hoặc lỗi lặp đã được báo cáo.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Description
When analyzing a GitHub organization that contains empty repositories (repositories with zero commits or no contributor activity), GitHub's REST API endpoint (GET /repos/{owner}/{repo}/contributors) returns an HTTP 204 No Content status code with an empty response body.
In src/services/github.js, fetchWithCache treats any response where res.ok is true (status 200–299) as JSON and attempts to parse it via await res.json():
// src/services/github.js (Lines 78-82)
if (!res.ok) throw new Error(`HTTP_${res.status}`)
const data = await res.json()
cacheSet(url, data)
return data
Because res.status === 204 has no body, calling res.json() throws an unhandled:
SyntaxError: Unexpected end of JSON input
Furthermore, in caller functions such as fetchContributors, fetchRepos, fetchIssues, and fetchPulls, the return value is spread directly into an array without verifying that data is an array:
// src/services/github.js (Lines 106-108)
const data = await fetchWithCache(url, pat)
all.push(...data)
if (data.length < 100) break
If data is empty, null, or not an array, spreading ...data throws an unhandled:
TypeError: data is not iterable
This causes exploration to fail or drop repositories when analyzing organizations that have placeholder, archived, or newly initialized empty repositories.
Steps to Reproduce
- Open OrgExplorer home page.
- Search for any GitHub organization that contains one or more empty repositories (e.g., an org with newly created repos that have no commits pushed).
- Click EXPLORE (or run complete analysis with a PAT).
- Open browser DevTools Console.
- Notice the uncaught
SyntaxError: Unexpected end of JSON inputwhen fetching contributors for the empty repo.
Logs and Screenshots
GET https://api.github.com/repos/{org}/{empty-repo}/contributors?per_page=100&page=1 204 (No Content)
Uncaught (in promise) SyntaxError: Unexpected end of JSON input
at fetchWithCache (github.js:80)
at async fetchContributors (github.js:106)
at async AppContext.jsx:120
Uncaught (in promise) TypeError: data is not iterable
at fetchContributors (github.js:107)
Environment Details
- OS: Windows 11 / macOS / Linux
- Browser: Google Chrome, Mozilla Firefox, Safari
- Component:
src/services/github.js(fetchWithCache,fetchContributors,fetchRepos,fetchIssues,fetchPulls)
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
- 48
- Fork
- 163
- Merge trung bình
- 5 ngày 2 giờ
- Pull request đã merge (30 ngày)
- 31
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AOSSIE-Org/OrgExplorer
-
[BUG]: Table sort headers can't be used from the keyboard and don't announce sort orderCó thể đã có người làm @Simran-Sobhani đã nhận 4 ngày trước. Đang mởbug enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AOSSIE-Org/OrgExplorer#419 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
[BUG]: Connect PAT modal saves invalid GitHub tokens without validationCó thể đã có người làm @Prince-ES đã nhận 6 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
AOSSIE-Org/OrgExplorer#416 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
[BUG]: Avoid triggering Release Drafter for closed, unmerged pull requestsCó thể đã có người làm @Praveena2809 đã nhận 4 ngày trước. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
AOSSIE-Org/OrgExplorer#414 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
[BUG]: Overview "Language Distribution" percentages are relative to the top-7 languages, not all reposCó thể đã có người làm @Rohit270406 đã nhận 9 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
AOSSIE-Org/OrgExplorer#402 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
[BUG]: Overview wrongly lists a successfully-loaded org as "could not be loaded" (case / duplicate)Có thể đã có người làm @Rajvardhan-Singh-Rathore đã nhận 4 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
AOSSIE-Org/OrgExplorer#400 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của AOSSIE-Org/OrgExplorer
Issue tương tự
-
Missing ACL in OpenWRT v25.12.6Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
area: quality enhancement priority: should
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
TheOdinProject/curriculum#31509 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
d-dev0101/open-sea-skin#25 · 1 bình luận ·
-
type:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
nightgauge/nightgauge#2836 ·
Maintainer thường phản hồi trong vòng 1 ngày