anuraghazra/github-readme-stats · error · Error

Gist not found

Error message

Gist not found

What it means

Thrown by fetchGist when the GraphQL call succeeded with no errors array but res.data.data.viewer.gist is null/undefined. In the gist query, viewer.gist(name:) returns null when no gist with that name is visible to the token, so a non-existent or inaccessible ID lands here rather than in the errors branch.

Source

Thrown at src/fetchers/gist.js:98

 * @typedef {import('./types').GistData} GistData Gist data.
 */

/**
 * Fetch GitHub gist information by given username and ID.
 *
 * @param {string} id GitHub gist ID.
 * @returns {Promise<GistData>} Gist data.
 */
const fetchGist = async (id) => {
  if (!id) {
    throw new MissingParamError(["id"], "/api/gist?id=GIST_ID");
  }
  const res = await retryer(fetcher, { gistName: id });
  if (res.data.errors) {
    throw new Error(res.data.errors[0].message);
  }
  if (!res.data.data.viewer.gist) {
    throw new Error("Gist not found");
  }
  const data = res.data.data.viewer.gist;
  return {
    name: data.files[Object.keys(data.files)[0]].name,
    nameWithOwner: `${data.owner.login}/${
      data.files[Object.keys(data.files)[0]].name
    }`,
    description: data.description,
    language: calculatePrimaryLanguage(data.files),
    starsCount: data.stargazerCount,
    forksCount: data.forks.totalCount,
  };
};

export { fetchGist };
export default fetchGist;

View on GitHub (pinned to 54a7985aee)

Solutions

  1. Open https://gist.github.com/<your-user>/<id> in a browser to confirm the gist still exists and is public.
  2. If it was deleted, regenerate it and update the URL with the new ID.
  3. If it is secret, make it public or switch to a PAT owned by the gist author.

Example fix

// before
// GET /api/gist?id=<deleted_gist_id>  -> 'Gist not found'

// after
// GET /api/gist?id=<current_public_gist_id>
Defensive patterns

Strategy: try-catch

Validate before calling

// Optional pre-check that the gist is reachable from the configured token.
async function gistExists(id, token) {
  const r = await fetch(`https://api.github.com/gists/${id}`, {
    headers: { Authorization: `token ${token}` },
  });
  return r.ok;
}

Try / catch

// Treat 'Gist not found' as a 404-equivalent.
try {
  return await fetchGist(id);
} catch (err) {
  if (err.message === "Gist not found") return null; // caller renders a 404
  throw err;
}

Prevention

When it happens

Trigger: The gist ID resolves to no gist from the token's point of view: the gist was deleted; the ID is a valid-format hash that never existed; or the gist is secret and owned by a different account (GitHub returns null rather than an error for non-visible secret gists).

Common situations: A bookmarked/cached URL pointing at a since-deleted gist; a typo in the ID that still looks like a hash; or attempting to read another user's secret gist.

Related errors


AI-assisted analysis of anuraghazra/github-readme-stats@54a7985aee (2026-08-12). Data as JSON: /api/errors/2be8af0c12620d69. Report an issue: GitHub.