anuraghazra/github-readme-stats · error · Error
${res.data.errors[0].message}
Error message
${res.data.errors[0].message} What it means
Thrown by fetchGist when the GitHub GraphQL response carries a top-level errors array (res.data.errors is truthy). The thrown Error's message is the raw message from the first GraphQL error, so the visible text is whatever GitHub returned. Because fetchGist queries viewer { gist(name: $gistName) }, the error is evaluated against the token's identity, meaning a secret gist owned by another account, a malformed ID, or a service issue all surface here.
Source
Thrown at src/fetchers/gist.js:95
};
/**
* @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 };View on GitHub (pinned to 54a7985aee)
Solutions
- Confirm the gist is public (or that the PAT_1 token belongs to the gist owner).
- Verify the gist ID matches the full hash in the gist URL (e.g. https://gist.github.com/<user>/<id>).
- If the message mentions permissions/scopes, regenerate the token with the 'gist' scope or use a public gist.
- Retry once after a short delay — transient GitHub GraphQL errors are common.
Example fix
// before: secret gist pinned by a token that doesn't own it // GET /api/gist?id=<secret_gist_id> -> GraphQL error: permission denied // after: make the gist public, or use a token owned by the gist author // (gist settings > 'Make public')
Defensive patterns
Strategy: try-catch
Validate before calling
// Sanity-check the gist id shape before the call (reduces, not eliminates, GraphQL errors).
function looksLikeGistId(id) {
return typeof id === "string" && /^[0-9a-f]{6,}$/i.test(id);
} Try / catch
// Surface the GraphQL message but degrade gracefully.
try {
const data = await fetchGist(id);
} catch (err) {
// err.message is the raw GraphQL error text; render a fallback card.
return renderError({ message: err.message });
} Prevention
- Prefer public gists, or ensure PAT_1 is owned by the gist author when pinning secret gists.
- Treat any permission-flavored message as a signal to regenerate the token with the 'gist' scope.
When it happens
Trigger: GraphQL returns errors for the gist query: a malformed gist ID; a gist that exists but is secret and not owned by the configured PAT's user; a transient GitHub 'Something went wrong while executing your query'; or a token whose scopes cannot read gist metadata.
Common situations: Trying to pin a secret gist with a token that doesn't own it; copy-pasting only part of the gist hash; pointing at a gist that was deleted after the cache TTL; or a token lacking the 'gist' scope on classic tokens.
Related errors
AI-assisted analysis of anuraghazra/github-readme-stats@54a7985aee (2026-08-12).
Data as JSON: /api/errors/14573d5539cd7e5b.
Report an issue: GitHub.