Mintplex-Labs/anything-llm · error

[GitHub Loader]: not in ready state!

Error message

[GitHub Loader]: not in ready state!

What it means

GitHubRepoLoader.recursiveLoader requires ready===true from init(). Same pattern as Gitea — init() returns undefined if #validGithubUrl() fails (hostname not github.com, pathname malformed), leaving ready false.

Source

Thrown at collector/utils/extensions/RepoLoader/GithubRepo/RepoLoader/index.js:151

  /**
   * Initializes the RepoLoader instance.
   * @returns {Promise<RepoLoader>} The initialized RepoLoader instance.
   */
  async init() {
    if (!this.#validGithubUrl()) return;
    await this.#validBranch();
    await this.#validateAccessToken();
    this.ready = true;
    return this;
  }

  /**
   * Recursively loads the repository content.
   * @returns {Promise<Array<Object>>} An array of loaded documents.
   * @throws {Error} If the RepoLoader is not in a ready state.
   */
  async recursiveLoader() {
    if (!this.ready) throw new Error("[GitHub Loader]: not in ready state!");
    const {
      GithubRepoLoader: LCGithubLoader,
    } = require("@langchain/community/document_loaders/web/github");

    if (this.accessToken)
      console.log(
        `[GitHub Loader]: Access token set! Recursive loading enabled!`
      );

    const loader = new LCGithubLoader(this.repo, {
      branch: this.branch,
      recursive: !!this.accessToken, // Recursive will hit rate limits.
      maxConcurrency: 5,
      unknown: "warn",
      accessToken: this.accessToken,
      ignorePaths: this.ignorePaths,
      verbose: true,
    });

View on GitHub (pinned to 526360e320)

Solutions

  1. Await init() and verify the returned instance is truthy.
  2. Ensure the repo URL is exactly github.com/{author}/{project}.
  3. Call recursiveLoader only after a successful init.

Example fix

// before
const loader = new GitHubRepoLoader({ repo });
await loader.recursiveLoader();

// after
const loader = await new GitHubRepoLoader({ repo }).init();
if (!loader?.ready) throw new Error("Invalid GitHub URL");
await loader.recursiveLoader();
Defensive patterns

Strategy: validation

Validate before calling

async function buildGithubLoader(args) {
  const loader = await new GitHubRepoLoader(args).init();
  return loader?.ready ? loader : null;
}

Type guard

function isReady(loader) { return !!loader && loader.ready === true; }

Try / catch

try { await loader.recursiveLoader(); }
catch (e) {
  if (e.message === "[GitHub Loader]: not in ready state!") { /* fix URL / re-init */ }
  throw e;
}

Prevention

When it happens

Trigger: recursiveLoader called without awaiting init(), or init() returned because the URL is not a valid github.com/{author}/{project} URL (wrong hostname, missing author/project).

Common situations: Passed a non-GitHub URL (GitLab/Gitea/Bitbucket); forgot init(); URL has extra path segments breaking author/project parsing.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/55807996203fc030. Report an issue: GitHub.