{"record":{"id":"d054bcd385735dcf","repo":"Mintplex-Labs/anything-llm","slug":"gitea-loader-not-in-ready-state","errorCode":null,"errorMessage":"[Gitea Loader]: not in ready state!","messagePattern":"\\[Gitea Loader\\]: not in ready state!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"collector/utils/extensions/RepoLoader/GiteaRepo/RepoLoader/index.js","lineNumber":164,"sourceCode":"  /**\n   * Initializes the RepoLoader instance.\n   * @returns {Promise<GiteaRepoLoader>} The initialized RepoLoader instance.\n   */\n  async init() {\n    if (!this.#validGiteaUrl()) 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(\"[Gitea Loader]: not in ready state!\");\n\n    if (this.accessToken)\n      console.log(\n        `[Gitea Loader]: Access token set! Recursive loading enabled for ${this.repo}!`\n      );\n\n    const docs = [];\n\n    console.log(`[Gitea Loader]: Fetching files.`);\n    const files = await this.fetchFilesRecursive();\n    console.log(`[Gitea Loader]: Fetched ${files.length} files.`);\n\n    for (const file of files) {\n      if (this.ignoreFilter.ignores(file.path)) continue;\n\n      docs.push({\n        pageContent: file.content,\n        metadata: {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/utils/extensions/RepoLoader/GiteaRepo/RepoLoader/index.js#L146-L182","documentation":"GiteaRepoLoader.recursiveLoader requires ready===true, set by init(). If init() was never called, or returned early because #validGiteaUrl() failed (invalid protocol/pathname), ready stays false and this throws. Note init() returns undefined silently on a bad URL rather than throwing.","triggerScenarios":"Caller instantiates the loader and calls recursiveLoader() without awaiting init(), or init() returned undefined because the repo URL failed #validGiteaUrl (non-http(s) protocol, or pathname not {author}/{project}).","commonSituations":"Forgot to call/await init(); the Gitea URL is malformed; URL has trailing view paths that were not normalized; init() swallowed the validation failure silently.","solutions":["Always `const loader = await new GiteaRepoLoader(args).init();` and assert the return is truthy before loading.","If init() returned falsy, fix the URL per #validGiteaUrl's checks (http(s) protocol, {host}/{author}/{project} pathname).","Do not call recursiveLoader until init resolves with the instance."],"exampleFix":"// before\nconst loader = new GiteaRepoLoader({ repo });\nawait loader.recursiveLoader(); // ready is false -> throws\n\n// after\nconst loader = await new GiteaRepoLoader({ repo }).init();\nif (!loader?.ready) throw new Error(\"Invalid Gitea repo URL\");\nawait loader.recursiveLoader();","handlingStrategy":"validation","validationCode":"async function buildGiteaLoader(args) {\n  const loader = await new GiteaRepoLoader(args).init();\n  return loader?.ready ? loader : null;\n}","typeGuard":"function isReady(loader) {\n  return !!loader && loader.ready === true;\n}","tryCatchPattern":"try { await loader.recursiveLoader(); }\ncatch (e) {\n  if (e.message === \"[Gitea Loader]: not in ready state!\") { /* re-init / fix URL */ }\n  throw e;\n}","preventionTips":["Always await init() and assert the return is the instance.","Make init() throw on invalid URL rather than returning undefined.","Guard recursiveLoader callers with isReady."],"tags":["gitea","repo-loader","state","initialization"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}