anuraghazra/github-readme-stats · error · MissingParamError

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

Error message

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

What it means

MissingParamError thrown by fetchGist when the 'id' argument is falsy before any network call. The constructor builds the message 'Missing params "id" make sure you pass the parameters in URL' and attaches a secondaryMessage of '/api/gist?id=GIST_ID' so the rendered error card shows a correct example URL.

Source

Thrown at src/fetchers/gist.js:91

    }
  }

  return primaryLanguage;
};

/**
 * @typedef {import('./types').GistData} GistData Gist data.
 */

/**
 * Fetch GitHub gist information by given username and ID.
 *
 * @param {string} id GitHub gist ID.
 * @returns {Promise<GistData>} Gist data.
 */
const fetchGist = async (id) => {
  if (!id) {
    throw new MissingParamError(["id"], "/api/gist?id=GIST_ID");
  }
  const res = await retryer(fetcher, { gistName: id });
  if (res.data.errors) {
    throw new Error(res.data.errors[0].message);
  }
  if (!res.data.data.viewer.gist) {
    throw new Error("Gist not found");
  }
  const data = res.data.data.viewer.gist;
  return {
    name: data.files[Object.keys(data.files)[0]].name,
    nameWithOwner: `${data.owner.login}/${
      data.files[Object.keys(data.files)[0]].name
    }`,
    description: data.description,
    language: calculatePrimaryLanguage(data.files),
    starsCount: data.stargazerCount,
    forksCount: data.forks.totalCount,

View on GitHub (pinned to 54a7985aee)

Solutions

  1. Append a real gist ID: /api/gist?id=<gist_id> where <gist_id> is the hash from the gist URL.
  2. If building the URL programmatically, guard that id is a non-empty string before issuing the request.
  3. Double-check the param name is 'id' (not 'gist', 'gist_id', or 'name').

Example fix

// before
// GET /api/gist

// after
// GET /api/gist?id=aa5a315d61ae9438b18d
Defensive patterns

Strategy: validation

Validate before calling

// Validate the gist id is a non-empty hex-ish string before calling fetchGist.
function requireGistId(id) {
  if (!id || typeof id !== "string" || !/^[0-9a-f]+$/i.test(id)) {
    throw new Error("Missing or malformed gist id; expected /api/gist?id=<hex>");
  }
}

Type guard

// Narrow an unknown query value to a usable gist id.
function isGistId(v) {
  return typeof v === "string" && /^[0-9a-f]+$/i.test(v);
}

Prevention

When it happens

Trigger: A request to /api/gist with no id query parameter (or id empty), e.g. GET /api/gist or GET /api/gist?id=. The api/gist.js handler passes req.query.gist_id (or equivalent) straight into fetchGist, which fails the !id guard.

Common situations: User copies the gist URL pattern but forgets to substitute the actual gist ID; a templating layer strips the id param; or the wrong query key is used (e.g. ?gist= instead of ?id=).

Related errors


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