{"record":{"id":"55807996203fc030","repo":"Mintplex-Labs/anything-llm","slug":"github-loader-not-in-ready-state","errorCode":null,"errorMessage":"[GitHub Loader]: not in ready state!","messagePattern":"\\[GitHub Loader\\]: not in ready state!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/utils/extensions/RepoLoader/GithubRepo/RepoLoader/index.js","lineNumber":151,"sourceCode":"  /**\n   * Initializes the RepoLoader instance.\n   * @returns {Promise<RepoLoader>} The initialized RepoLoader instance.\n   */\n  async init() {\n    if (!this.#validGithubUrl()) return;\n    await this.#validBranch();\n    await this.#validateAccessToken();\n    this.ready = true;\n    return this;\n  }\n\n  /**\n   * Recursively loads the repository content.\n   * @returns {Promise<Array<Object>>} An array of loaded documents.\n   * @throws {Error} If the RepoLoader is not in a ready state.\n   */\n  async recursiveLoader() {\n    if (!this.ready) throw new Error(\"[GitHub Loader]: not in ready state!\");\n    const {\n      GithubRepoLoader: LCGithubLoader,\n    } = require(\"@langchain/community/document_loaders/web/github\");\n\n    if (this.accessToken)\n      console.log(\n        `[GitHub Loader]: Access token set! Recursive loading enabled!`\n      );\n\n    const loader = new LCGithubLoader(this.repo, {\n      branch: this.branch,\n      recursive: !!this.accessToken, // Recursive will hit rate limits.\n      maxConcurrency: 5,\n      unknown: \"warn\",\n      accessToken: this.accessToken,\n      ignorePaths: this.ignorePaths,\n      verbose: true,\n    });","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/extensions/RepoLoader/GithubRepo/RepoLoader/index.js#L133-L169","documentation":"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.","triggerScenarios":"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).","commonSituations":"Passed a non-GitHub URL (GitLab/Gitea/Bitbucket); forgot init(); URL has extra path segments breaking author/project parsing.","solutions":["Await init() and verify the returned instance is truthy.","Ensure the repo URL is exactly github.com/{author}/{project}.","Call recursiveLoader only after a successful init."],"exampleFix":"// before\nconst loader = new GitHubRepoLoader({ repo });\nawait loader.recursiveLoader();\n\n// after\nconst loader = await new GitHubRepoLoader({ repo }).init();\nif (!loader?.ready) throw new Error(\"Invalid GitHub URL\");\nawait loader.recursiveLoader();","handlingStrategy":"validation","validationCode":"async function buildGithubLoader(args) {\n  const loader = await new GitHubRepoLoader(args).init();\n  return loader?.ready ? loader : null;\n}","typeGuard":"function isReady(loader) { return !!loader && loader.ready === true; }","tryCatchPattern":"try { await loader.recursiveLoader(); }\ncatch (e) {\n  if (e.message === \"[GitHub Loader]: not in ready state!\") { /* fix URL / re-init */ }\n  throw e;\n}","preventionTips":["Await init() and check the result before loading.","Validate the URL is github.com/{author}/{project}.","Have init() throw on invalid URLs."],"tags":["github","repo-loader","state","initialization"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}