anuraghazra/github-readme-stats · error · MissingParamError

Missing params "username" make sure you pass the parameters

Error message

Missing params "username" make sure you pass the parameters in URL

What it means

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'.

Source

Thrown at src/fetchers/stats.js:237

 * @param {boolean} include_all_commits Include all commits.
 * @param {string[]} exclude_repo Repositories to exclude.
 * @param {boolean} include_merged_pull_requests Include merged pull requests.
 * @param {boolean} include_discussions Include discussions.
 * @param {boolean} include_discussions_answers Include discussions answers.
 * @param {number|undefined} commits_year Year to count total commits
 * @returns {Promise<import("./types").StatsData>} Stats data.
 */
const fetchStats = async (
  username,
  include_all_commits = false,
  exclude_repo = [],
  include_merged_pull_requests = false,
  include_discussions = false,
  include_discussions_answers = false,
  commits_year,
) => {
  if (!username) {
    throw new MissingParamError(["username"]);
  }

  const stats = {
    name: "",
    totalPRs: 0,
    totalPRsMerged: 0,
    mergedPRsPercentage: 0,
    totalReviews: 0,
    totalCommits: 0,
    totalIssues: 0,
    totalStars: 0,
    totalDiscussionsStarted: 0,
    totalDiscussionsAnswered: 0,
    contributedTo: 0,
    rank: { level: "C", percentile: 100 },
  };

  let res = await statsFetcher({

View on GitHub (pinned to 54a7985aee)

Solutions

  1. Add the username: /api/?username=<login>.
  2. When generating the URL programmatically, assert username is non-empty before requesting.
  3. Confirm the param key is exactly 'username'.

Example fix

// before
// GET /api/

// after
// GET /api/?username=anuraghazra
Defensive patterns

Strategy: validation

Validate before calling

function requireStatsUsername(username) {
  if (!username || typeof username !== "string") {
    throw new Error("username is required: /api/?username=LOGIN");
  }
}

Type guard

const isNonEmptyString = (v) => typeof v === "string" && v.trim().length > 0;

Prevention

When it happens

Trigger: 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.

Common situations: 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=).

Related errors


AI-assisted analysis of anuraghazra/github-readme-stats@54a7985aee (2026-08-12). Data as JSON: /api/errors/b0959753882a7e47. Report an issue: GitHub.