{"record":{"id":"14573d5539cd7e5b","repo":"anuraghazra/github-readme-stats","slug":"res-data-errors-0-message","errorCode":null,"errorMessage":"${res.data.errors[0].message}","messagePattern":"\\$\\{res\\.data\\.errors\\[0\\]\\.message\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/fetchers/gist.js","lineNumber":95,"sourceCode":"};\n\n/**\n * @typedef {import('./types').GistData} GistData Gist data.\n */\n\n/**\n * Fetch GitHub gist information by given username and ID.\n *\n * @param {string} id GitHub gist ID.\n * @returns {Promise<GistData>} Gist data.\n */\nconst fetchGist = async (id) => {\n  if (!id) {\n    throw new MissingParamError([\"id\"], \"/api/gist?id=GIST_ID\");\n  }\n  const res = await retryer(fetcher, { gistName: id });\n  if (res.data.errors) {\n    throw new Error(res.data.errors[0].message);\n  }\n  if (!res.data.data.viewer.gist) {\n    throw new Error(\"Gist not found\");\n  }\n  const data = res.data.data.viewer.gist;\n  return {\n    name: data.files[Object.keys(data.files)[0]].name,\n    nameWithOwner: `${data.owner.login}/${\n      data.files[Object.keys(data.files)[0]].name\n    }`,\n    description: data.description,\n    language: calculatePrimaryLanguage(data.files),\n    starsCount: data.stargazerCount,\n    forksCount: data.forks.totalCount,\n  };\n};\n\nexport { fetchGist };","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/anuraghazra/github-readme-stats/blob/54a7985aeefda00d5eadb55b80c17c7f976c37d2/src/fetchers/gist.js#L77-L113","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: secret gist pinned by a token that doesn't own it\n// GET /api/gist?id=<secret_gist_id>  -> GraphQL error: permission denied\n\n// after: make the gist public, or use a token owned by the gist author\n// (gist settings > 'Make public')","handlingStrategy":"try-catch","validationCode":"// Sanity-check the gist id shape before the call (reduces, not eliminates, GraphQL errors).\nfunction looksLikeGistId(id) {\n  return typeof id === \"string\" && /^[0-9a-f]{6,}$/i.test(id);\n}","typeGuard":null,"tryCatchPattern":"// Surface the GraphQL message but degrade gracefully.\ntry {\n  const data = await fetchGist(id);\n} catch (err) {\n  // err.message is the raw GraphQL error text; render a fallback card.\n  return renderError({ message: err.message });\n}","preventionTips":["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."],"tags":["gist","graphql","github-api","permissions"],"backgroundTag":null,"analyzedSha":"54a7985aeefda00d5eadb55b80c17c7f976c37d2","analyzedAt":"2026-08-12T23:20:41.776Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}