[BUG]: `fetchWithCache` crashes with `SyntaxError: Unexpected end of JSON input` when encountering empty repositories (HTTP 204 No Content)

オープン 初心者向け
#433 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 4 日以内に返信

@Devnil434 がすでに取り組んでいます。

2026年10月29日 から。

  • #434 @Devnil434 による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
github, javascript
領域
api, backend

調査の方向性

src/services/github.js の fetchWithCache と呼び出し元の fetchContributors、fetchRepos、fetchIssues、fetchPulls から確認します。コードが成功応答 204 No Content をどのように処理するか、また呼び出し元のデータが反復可能かを確認し、空のリポジトリの contributors エンドポイントで再現します。空のリポジトリを含む組織の探索が、報告された JSON の解析エラーや反復エラーなしで完了すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug
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
  1. Open OrgExplorer home page.
  2. 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).
  3. Click EXPLORE (or run complete analysis with a PAT).
  4. Open browser DevTools Console.
  5. Notice the uncaught SyntaxError: Unexpected end of JSON input when 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
フォーク
169
平均マージ
4日 13時間
マージ済み PR(30日)
25

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AOSSIE-Org/OrgExplorer のほかの issue

AOSSIE-Org/OrgExplorer の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。