{"record":{"id":"f5e1cf16a7cb127d","repo":"anuraghazra/github-readme-stats","slug":"wakatime-user-not-found","errorCode":"WAKATIME_USER_NOT_FOUND","errorMessage":"Could not resolve to a User with the login of '${username}'","messagePattern":"Could not resolve to a User with the login of '(.+?)'","errorType":"error_code","errorClass":"CustomError","httpStatus":null,"severity":"error","filePath":"src/fetchers/wakatime.js","lineNumber":27,"sourceCode":" * @param {{username: string, api_domain: string }} props Fetcher props.\n * @returns {Promise<import(\"./types\").WakaTimeData>} WakaTime data response.\n */\nconst fetchWakatimeStats = async ({ username, api_domain }) => {\n  if (!username) {\n    throw new MissingParamError([\"username\"]);\n  }\n\n  try {\n    const { data } = await axios.get(\n      `https://${\n        api_domain ? api_domain.replace(/\\/$/gi, \"\") : \"wakatime.com\"\n      }/api/v1/users/${username}/stats?is_including_today=true`,\n    );\n\n    return data.data;\n  } catch (err) {\n    if (err.response.status < 200 || err.response.status > 299) {\n      throw new CustomError(\n        `Could not resolve to a User with the login of '${username}'`,\n        \"WAKATIME_USER_NOT_FOUND\",\n      );\n    }\n    throw err;\n  }\n};\n\nexport { fetchWakatimeStats };\nexport default fetchWakatimeStats;\n","sourceCodeStart":9,"sourceCodeEnd":38,"githubUrl":"https://github.com/anuraghazra/github-readme-stats/blob/54a7985aeefda00d5eadb55b80c17c7f976c37d2/src/fetchers/wakatime.js#L9-L38","documentation":"Raised when the WakaTime REST GET returns any non-2xx status: the condition `err.response.status < 200 || err.response.status > 299` maps every non-success HTTP code to a single WAKATIME_USER_NOT_FOUND type, which is imprecise (a 401, 500, or 503 is labeled 'user not found'). The secondary message (src/common/error.js:19) is \"Make sure you have a public WakaTime profile\", pointing at the most common real cause: a private or nonexistent WakaTime profile. Note the latent bug: if axios has no response object (DNS failure, timeout, network error), err.response is undefined and `err.response.status` throws a TypeError before this CustomError can be constructed.","triggerScenarios":"The axios GET to https://<api_domain|wakatime.com>/api/v1/users/<username>/stats?is_including_today=true returns a non-2xx status with a response object. Concretely: 404 for a user that does not exist; 401/403 when the WakaTime profile is private or the self-hosted api_domain requires auth; 5xx during a WakaTime outage; a custom api_domain that is wrong or unreachable-but-responding.","commonSituations":"The WakaTime profile is set to private (Account Settings > not public); a typo'd WakaTime username; a self-hosted WakaTime instance (api_domain) that returns 401 without API key auth; a WakaTime service outage; pointing api_domain at the wrong host that still returns an HTTP error.","solutions":["In WakaTime, set the profile to public (Settings > and enable the public profile), which is the cause implied by the secondary message.","Verify the username exists by opening https://wakatime.com/@<username>.","If using a custom api_domain, confirm it is correct, reachable, and does not require authentication this fetcher does not send.","Check https://status.wakatime.com for an active outage when the username and profile are known-good.","Guard against network-level failures: if err.response is undefined (no response), do not dereference err.response.status; surface the network error instead."],"exampleFix":"// before\n} catch (err) {\n  if (err.response.status < 200 || err.response.status > 299) {\n    throw new CustomError(\n      `Could not resolve to a User with the login of '${username}'`,\n      \"WAKATIME_USER_NOT_FOUND\",\n    );\n  }\n  throw err;\n}\n\n// after (distinguish 404 from other statuses, avoid crash on no response)\n} catch (err) {\n  const status = err.response?.status;\n  if (status === 404) {\n    throw new CustomError(\n      `Could not resolve to a User with the login of '${username}'`,\n      \"WAKATIME_USER_NOT_FOUND\",\n    );\n  }\n  throw err; // 401/500/network errors surface with their real cause\n}","handlingStrategy":"try-catch","validationCode":"// Preflight the WakaTime profile is public before relying on fetchWakatimeStats\nasync function assertWakatimeProfilePublic(username, api_domain) {\n  const base = api_domain ? api_domain.replace(/\\/$/i, \"\") : \"wakatime.com\";\n  const resp = await axios.get(\n    `https://${base}/api/v1/users/${username}/stats?is_including_today=true`,\n    { validateStatus: () => true },\n  );\n  if (resp.status === 404) throw new Error(`WakaTime user '${username}' not found`);\n  if (resp.status === 401 || resp.status === 403) {\n    throw new Error(`WakaTime profile for '${username}' is private; enable public profile`);\n  }\n  if (resp.status < 200 || resp.status > 299) {\n    throw new Error(`WakaTime API returned ${resp.status}`);\n  }\n}\n// call before fetchWakatimeStats to fail with a precise message","typeGuard":"function isWakatimeUserNotFound(err) {\n  return err instanceof CustomError && err.type === \"WAKATIME_USER_NOT_FOUND\";\n}","tryCatchPattern":"try {\n  const stats = await fetchWakatimeStats({ username, api_domain });\n} catch (err) {\n  // Guard the latent crash: a network error has no err.response\n  if (!err.response && !(err instanceof CustomError)) {\n    throw new Error(\"Network error contacting WakaTime API\");\n  }\n  if (err instanceof CustomError && err.type === \"WAKATIME_USER_NOT_FOUND\") {\n    return res.send(renderError({\n      message: err.message,\n      secondaryMessage: \"Make sure you have a public WakaTime profile\",\n    }));\n  }\n  throw err;\n}","preventionTips":["Set the WakaTime profile to public (the cause named by the secondary message) before wiring the card.","Confirm the username opens at https://wakatime.com/@<username>.","If using api_domain for a self-hosted instance, ensure it does not require auth this fetcher cannot provide.","Note the fetcher crashes (TypeError) when err.response is undefined — handle network errors before checking status."],"tags":["wakatime","http","user-not-found","upstream","fragile-code"],"backgroundTag":null,"analyzedSha":"54a7985aeefda00d5eadb55b80c17c7f976c37d2","analyzedAt":"2026-08-12T23:20:41.776Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}