anuraghazra/github-readme-stats · error · MissingParamError

Missing params "username", "repo" make sure you pass the par

Error message

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

What it means

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&repo=REPO_NAME') as the secondary message so the error card shows the expected shape.

Source

Thrown at src/fetchers/repo.js:71

  );
};

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;

View on GitHub (pinned to 54a7985aee)

Solutions

  1. Supply both params: /api/pin?username=<owner>&repo=<name>.
  2. When building the URL dynamically, assert both fields are non-empty before requesting.
  3. Confirm the keys are exactly 'username' and 'repo'.

Example fix

// before
// GET /api/pin

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

Strategy: validation

Validate before calling

// Require both owner and repo before calling fetchRepo.
function requireRepoParams(username, repo) {
  if (!username && !repo) {
    throw new Error("Both username and repo are required: /api/pin?username=OWNER&repo=NAME");
  }
}

Prevention

When it happens

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

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

Related errors


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