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 fetchRepo when reponame is present (truthy) but username is falsy. The constructor reports only "username" as missing and reuses urlExample as the secondary message. The order of the three guards means this branch is only reached when (!username && !reponame) was false, i.e. repo was supplied.

Source

Thrown at src/fetchers/repo.js:74

const urlExample = "/api/pin?username=USERNAME&repo=REPO_NAME";

/**
 * @typedef {import("./types").RepositoryData} RepositoryData Repository data.
 */

/**
 * Fetch repository data.
 *
 * @param {string} username GitHub username.
 * @param {string} reponame GitHub repository name.
 * @returns {Promise<RepositoryData>} Repository data.
 */
const fetchRepo = async (username, reponame) => {
  if (!username && !reponame) {
    throw new MissingParamError(["username", "repo"], urlExample);
  }
  if (!username) {
    throw new MissingParamError(["username"], urlExample);
  }
  if (!reponame) {
    throw new MissingParamError(["repo"], urlExample);
  }

  let res = await retryer(fetcher, { login: username, repo: reponame });

  const data = res.data.data;

  if (!data.user && !data.organization) {
    throw new Error("Not found");
  }

  const isUser = data.organization === null && data.user;
  const isOrg = data.user === null && data.organization;

  if (isUser) {
    if (!data.user.repository || data.user.repository.isPrivate) {

View on GitHub (pinned to 54a7985aee)

Solutions

  1. Add the owner: /api/pin?username=<owner>&repo=<name>.
  2. Validate that username is non-empty before constructing the request URL.

Example fix

// before
// GET /api/pin?repo=github-readme-stats

// after
// GET /api/pin?username=anuraghazra&repo=github-readme-stats
Defensive patterns

Strategy: validation

Validate before calling

function requireUsername(username) {
  if (!username || typeof username !== "string") {
    throw new Error("username is required: /api/pin?username=OWNER&repo=NAME");
  }
}

Type guard

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

Prevention

When it happens

Trigger: A request like /api/pin?repo=github-readme-stats with no username. The combined-missing guard at line 70 is skipped (reponame is truthy), so execution falls to the username-only check at line 73.

Common situations: A URL template that interpolates the repo name but leaves the owner blank; copy-paste that dropped the username= segment; or a generator that has the repo but not the owner.

Related errors


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