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

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

Maintainers usually reply within 1 day

@Devnil434 is already working on this.

Since Oct 29, 2026.

  • #434 by @Devnil434 — open

Assessment

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

Research direction

Start in src/services/github.js at fetchWithCache and the callers fetchContributors, fetchRepos, fetchIssues, and fetchPulls. Check how the code handles a successful 204 No Content response and whether caller data is iterable; reproduce with an empty repository's contributors endpoint. Done when exploring an organization with empty repositories completes without the reported JSON parsing or iteration errors.

Written by the indexing model from the issue text.

Description

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
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.