{"record":{"id":"b0959753882a7e47","repo":"anuraghazra/github-readme-stats","slug":"missing-params-username-make-sure-you-pass-the-p-b09597","errorCode":null,"errorMessage":"Missing params \"username\" make sure you pass the parameters in URL","messagePattern":"Missing params \"username\" make sure you pass the parameters in URL","errorType":"validation","errorClass":"MissingParamError","httpStatus":null,"severity":"error","filePath":"src/fetchers/stats.js","lineNumber":237,"sourceCode":" * @param {boolean} include_all_commits Include all commits.\n * @param {string[]} exclude_repo Repositories to exclude.\n * @param {boolean} include_merged_pull_requests Include merged pull requests.\n * @param {boolean} include_discussions Include discussions.\n * @param {boolean} include_discussions_answers Include discussions answers.\n * @param {number|undefined} commits_year Year to count total commits\n * @returns {Promise<import(\"./types\").StatsData>} Stats data.\n */\nconst fetchStats = async (\n  username,\n  include_all_commits = false,\n  exclude_repo = [],\n  include_merged_pull_requests = false,\n  include_discussions = false,\n  include_discussions_answers = false,\n  commits_year,\n) => {\n  if (!username) {\n    throw new MissingParamError([\"username\"]);\n  }\n\n  const stats = {\n    name: \"\",\n    totalPRs: 0,\n    totalPRsMerged: 0,\n    mergedPRsPercentage: 0,\n    totalReviews: 0,\n    totalCommits: 0,\n    totalIssues: 0,\n    totalStars: 0,\n    totalDiscussionsStarted: 0,\n    totalDiscussionsAnswered: 0,\n    contributedTo: 0,\n    rank: { level: \"C\", percentile: 100 },\n  };\n\n  let res = await statsFetcher({","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/anuraghazra/github-readme-stats/blob/54a7985aeefda00d5eadb55b80c17c7f976c37d2/src/fetchers/stats.js#L219-L255","documentation":"MissingParamError thrown by fetchStats when username is falsy, before any network call. Unlike the repo/gist variants, this constructor is called with a single-element array and no secondaryMessage, so the rendered error card has no example URL hint — just 'Missing params \"username\" make sure you pass the parameters in URL'.","triggerScenarios":"A request to the stats endpoint with no username query parameter, e.g. GET /api/ or GET /api/?hide=stars. The api/index.js handler forwards req.query.username to fetchStats, which fails the !username guard.","commonSituations":"User hits /api/ bare; a README template left the username blank; or the param was sent under a wrong key (e.g. ?user= instead of ?username=).","solutions":["Add the username: /api/?username=<login>.","When generating the URL programmatically, assert username is non-empty before requesting.","Confirm the param key is exactly 'username'."],"exampleFix":"// before\n// GET /api/\n\n// after\n// GET /api/?username=anuraghazra","handlingStrategy":"validation","validationCode":"function requireStatsUsername(username) {\n  if (!username || typeof username !== \"string\") {\n    throw new Error(\"username is required: /api/?username=LOGIN\");\n  }\n}","typeGuard":"const isNonEmptyString = (v) => typeof v === \"string\" && v.trim().length > 0;","tryCatchPattern":null,"preventionTips":["Validate req.query.username at the handler before delegating to fetchStats.","Trim whitespace; reject empty strings explicitly."],"tags":["stats","missing-param","validation","query-params"],"backgroundTag":null,"analyzedSha":"54a7985aeefda00d5eadb55b80c17c7f976c37d2","analyzedAt":"2026-08-12T23:20:41.776Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}