[BUG]: `fetchWithCache` crashes with `SyntaxError: Unexpected end of JSON input` when encountering empty repositories (HTTP 204 No Content)
维护者通常 4 天内回复
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- github, javascript
调研方向
从 src/services/github.js 中的 fetchWithCache 及其调用方 fetchContributors、fetchRepos、fetchIssues 和 fetchPulls 开始。检查代码如何处理成功的 204 No Content 响应,以及调用方数据是否可迭代;使用空 repository 的 contributors endpoint 重现问题。当探索包含空 repository 的组织时,不再出现已报告的 JSON 解析或迭代错误,即为完成。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- JavaScript
- 星标
- 48
- 派生
- 163
- 平均合并
- 4 天 13 小时
- 30 天内合并 PR
- 25
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AOSSIE-Org/OrgExplorer 的其他 Issue
-
[BUG]: Table sort headers can't be used from the keyboard and don't announce sort order可能已有人在做 @Simran-Sobhani 于 5 天前认领。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 78/100
AOSSIE-Org/OrgExplorer#419 · 2 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Connect PAT modal saves invalid GitHub tokens without validation可能重新可做 @Prince-ES 于 8 天前认领,目前没有进行中的 PR。 未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
AOSSIE-Org/OrgExplorer#416 · 1 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Avoid triggering Release Drafter for closed, unmerged pull requests可能已有人在做 @Praveena2809 于 5 天前认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 82/100
AOSSIE-Org/OrgExplorer#414 · 2 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Overview "Language Distribution" percentages are relative to the top-7 languages, not all repos可能已有人在做 @Rohit270406 于 10 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
AOSSIE-Org/OrgExplorer#402 · 1 条评论 ·
维护者通常 4 天内回复
-
[BUG]: Overview wrongly lists a successfully-loaded org as "could not be loaded" (case / duplicate)可能已有人在做 @Rajvardhan-Singh-Rathore 于 6 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
AOSSIE-Org/OrgExplorer#400 · 2 条评论 ·
维护者通常 4 天内回复
查看 AOSSIE-Org/OrgExplorer 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
Analysis
难度 2/5 1-3 小时 新手友好度 72/100
SACGF/variantgrid#2615 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
-
ready-for-agent
难度 2/5 1-3 小时 新手友好度 78/100
LucasSantana-Dev/Lucky#2945 ·
维护者通常 1 天内回复