anuraghazra/github-readme-stats · error · CustomError

GRAPHQL_ERROR

GRAPHQL_ERROR

Error message

Something went wrong while trying to retrieve the language data using the GraphQL API.

What it means

The catch-all GraphQL failure: thrown when res.data.errors is present but the first error is neither type "NOT_FOUND" nor carries any message. It is the last-resort branch after the NOT_FOUND and message-bearing branches, indicating an unexpected/empty GraphQL error shape. The secondary message (src/common/error.js:17) is "Please try again later", signaling the library treats this as a transient upstream anomaly it cannot classify.

Source

Thrown at src/fetchers/top-languages.js:88

  }

  const res = await retryer(fetcher, { login: username });

  if (res.data.errors) {
    logger.error(res.data.errors);
    if (res.data.errors[0].type === "NOT_FOUND") {
      throw new CustomError(
        res.data.errors[0].message || "Could not fetch user.",
        CustomError.USER_NOT_FOUND,
      );
    }
    if (res.data.errors[0].message) {
      throw new CustomError(
        wrapTextMultiline(res.data.errors[0].message, 90, 1)[0],
        res.statusText,
      );
    }
    throw new CustomError(
      "Something went wrong while trying to retrieve the language data using the GraphQL API.",
      CustomError.GRAPHQL_ERROR,
    );
  }

  let repoNodes = res.data.data.user.repositories.nodes;
  /** @type {Record<string, boolean>} */
  let repoToHide = {};
  const allExcludedRepos = [...exclude_repo, ...excludeRepositories];

  // populate repoToHide map for quick lookup
  // while filtering out
  if (allExcludedRepos) {
    allExcludedRepos.forEach((repoName) => {
      repoToHide[repoName] = true;
    });
  }

View on GitHub (pinned to 54a7985aee)

Solutions

  1. Treat as transient: retry the request a few times with backoff before surfacing the error.
  2. Inspect logger.error(res.data.errors) output to see the unclassified error shape and report it if it persists.
  3. Check https://www.githubstatus.com for ongoing incidents.
  4. If persistent, capture the full raw GraphQL response and file an issue, since this branch exists precisely because the error could not be categorized.
Defensive patterns

Strategy: retry

Validate before calling

// No pre-call validation can prevent an unclassified upstream error.
// At most, assert the environment is healthy before issuing the request.
function assertEnv() {
  if (!process.env.PAT_1) throw new Error("PAT_1 missing");
}
assertEnv();

Type guard

function isGraphqlCatchAll(err) {
  return err instanceof CustomError && err.type === CustomError.GRAPHQL_ERROR;
}

Try / catch

async function fetchTopLangsResilient(username, attempts = 3) {
  for (let i = 0; i < attempts; i++) {
    try {
      return await fetchTopLanguages(username);
    } catch (err) {
      if (err instanceof CustomError && err.type === CustomError.GRAPHQL_ERROR && i < attempts - 1) {
        await new Promise((r) => setTimeout(r, 2 ** i * 500));
        continue;
      }
      throw err;
    }
  }
}

Prevention

When it happens

Trigger: res.data.errors exists and is an array, but errors[0].type !== "NOT_FOUND" AND errors[0].message is falsy/absent. This is an atypical GitHub response: e.g., an error object with only a path or locations field and no message, or an empty-message error returned during an upstream anomaly. The retryer has already consumed RATE_LIMITED cases, so this is not a rate-limit path.

Common situations: Rare GitHub API glitches that return malformed or message-less error objects; a future API contract change where errors carry a different shape; edge cases during GitHub deployments.

Related errors


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