{"record":{"id":"bce2189446895f26","repo":"anuraghazra/github-readme-stats","slug":"user-not-found","errorCode":"USER_NOT_FOUND","errorMessage":"Could not fetch user.","messagePattern":"Could not fetch user\\.","errorType":"error_code","errorClass":"CustomError","httpStatus":null,"severity":"error","filePath":"src/fetchers/stats.js","lineNumber":267,"sourceCode":"    totalDiscussionsStarted: 0,\n    totalDiscussionsAnswered: 0,\n    contributedTo: 0,\n    rank: { level: \"C\", percentile: 100 },\n  };\n\n  let res = await statsFetcher({\n    username,\n    includeMergedPullRequests: include_merged_pull_requests,\n    includeDiscussions: include_discussions,\n    includeDiscussionsAnswers: include_discussions_answers,\n    startTime: commits_year ? `${commits_year}-01-01T00:00:00Z` : undefined,\n  });\n\n  // Catch GraphQL errors.\n  if (res.data.errors) {\n    logger.error(res.data.errors);\n    if (res.data.errors[0].type === \"NOT_FOUND\") {\n      throw new CustomError(\n        res.data.errors[0].message || \"Could not fetch user.\",\n        CustomError.USER_NOT_FOUND,\n      );\n    }\n    if (res.data.errors[0].message) {\n      throw new CustomError(\n        wrapTextMultiline(res.data.errors[0].message, 90, 1)[0],\n        res.statusText,\n      );\n    }\n    throw new CustomError(\n      \"Something went wrong while trying to retrieve the stats data using the GraphQL API.\",\n      CustomError.GRAPHQL_ERROR,\n    );\n  }\n\n  const user = res.data.data.user;\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/anuraghazra/github-readme-stats/blob/54a7985aeefda00d5eadb55b80c17c7f976c37d2/src/fetchers/stats.js#L249-L285","documentation":"CustomError(USER_NOT_FOUND) thrown by fetchStats when the GraphQL stats response has an errors array whose first element has type === 'NOT_FOUND'. The message is res.data.errors[0].message if present, falling back to 'Could not fetch user.'. The secondary message ('Make sure the provided username is not an organization') reflects the most common cause: the stats query only inspects user(login:), so an organization login returns NOT_FOUND.","triggerScenarios":"The stats GraphQL query returns a NOT_FOUND error for the given login — typically because the login is an organization (the query has no organization(...) branch), the user does not exist, or the account was deleted/renamed.","commonSituations":"Passing an organization name to the stats endpoint (e.g. ?username=microsoft); a misspelled/deleted user; or a renamed account whose old login no longer resolves.","solutions":["Use a personal account login, not an organization (the stats card does not support orgs).","Confirm the account exists at https://github.com/<username>.","Fix typos and use the current login if renamed."],"exampleFix":"// before\n// GET /api/?username=microsoft  (organization -> USER_NOT_FOUND)\n\n// after\n// GET /api/?username=torvalds  (personal account)","handlingStrategy":"validation","validationCode":"// Reject organizations up front — the stats query has no organization() branch.\nasync function assertIsUser(login, token) {\n  const r = await fetch(`https://api.github.com/users/${login}`, {\n    headers: { Authorization: `token ${token}` },\n  });\n  const j = await r.json();\n  if (j.type === \"Organization\") {\n    throw new Error(`${login} is an organization; the stats card only supports user accounts.`);\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await fetchStats(username);\n} catch (err) {\n  if (err.type === CustomError.USER_NOT_FOUND) return null; // render a 'user not found' card\n  throw err;\n}","preventionTips":["The stats endpoint is user-only; route orgs to a different card or reject them at the handler.","Confirm the login at https://github.com/<username> before pinning."],"tags":["stats","not-found","organization","graphql","github-api"],"backgroundTag":null,"analyzedSha":"54a7985aeefda00d5eadb55b80c17c7f976c37d2","analyzedAt":"2026-08-12T23:20:41.776Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}