{"record":{"id":"f099fc5084dc5679","repo":"anuraghazra/github-readme-stats","slug":"missing-params-username-repo-make-sure-you-pa","errorCode":null,"errorMessage":"Missing params \"username\", \"repo\" make sure you pass the parameters in URL","messagePattern":"Missing params \"username\", \"repo\" make sure you pass the parameters in URL","errorType":"validation","errorClass":"MissingParamError","httpStatus":null,"severity":"error","filePath":"src/fetchers/repo.js","lineNumber":71,"sourceCode":"  );\n};\n\nconst urlExample = \"/api/pin?username=USERNAME&amp;repo=REPO_NAME\";\n\n/**\n * @typedef {import(\"./types\").RepositoryData} RepositoryData Repository data.\n */\n\n/**\n * Fetch repository data.\n *\n * @param {string} username GitHub username.\n * @param {string} reponame GitHub repository name.\n * @returns {Promise<RepositoryData>} Repository data.\n */\nconst fetchRepo = async (username, reponame) => {\n  if (!username && !reponame) {\n    throw new MissingParamError([\"username\", \"repo\"], urlExample);\n  }\n  if (!username) {\n    throw new MissingParamError([\"username\"], urlExample);\n  }\n  if (!reponame) {\n    throw new MissingParamError([\"repo\"], urlExample);\n  }\n\n  let res = await retryer(fetcher, { login: username, repo: reponame });\n\n  const data = res.data.data;\n\n  if (!data.user && !data.organization) {\n    throw new Error(\"Not found\");\n  }\n\n  const isUser = data.organization === null && data.user;\n  const isOrg = data.user === null && data.organization;","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/anuraghazra/github-readme-stats/blob/54a7985aeefda00d5eadb55b80c17c7f976c37d2/src/fetchers/repo.js#L53-L89","documentation":"MissingParamError thrown by fetchRepo on its first guard when BOTH username and reponame are falsy. The constructor reports both missing params (\"username\", \"repo\") and attaches urlExample ('/api/pin?username=USERNAME&amp;repo=REPO_NAME') as the secondary message so the error card shows the expected shape.","triggerScenarios":"A request to /api/pin with neither username nor repo in the query string, e.g. GET /api/pin or GET /api/pin?foo=bar. api/pin.js destructures req.query and passes username and repo straight to fetchRepo, which trips the !username && !reponame branch.","commonSituations":"User hits the pin endpoint root without params; a URL template failed to interpolate either value; or the params were sent under wrong keys (e.g. user= and repository=).","solutions":["Supply both params: /api/pin?username=<owner>&repo=<name>.","When building the URL dynamically, assert both fields are non-empty before requesting.","Confirm the keys are exactly 'username' and 'repo'."],"exampleFix":"// before\n// GET /api/pin\n\n// after\n// GET /api/pin?username=anuraghazra&repo=github-readme-stats","handlingStrategy":"validation","validationCode":"// Require both owner and repo before calling fetchRepo.\nfunction requireRepoParams(username, repo) {\n  if (!username && !repo) {\n    throw new Error(\"Both username and repo are required: /api/pin?username=OWNER&repo=NAME\");\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate at the handler: if (!username || !repo) respond with a 400 instead of reaching fetchRepo.","Use the documented urlExample as the canonical example in error responses."],"tags":["repo-card","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"}