{"record":{"id":"17744afa51a8d78f","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-sync-gitea-file-content-reason","errorCode":null,"errorMessage":"Failed to sync Gitea file content. ${reason}","messagePattern":"Failed to sync Gitea file content\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":200,"severity":"error","filePath":"collector/extensions/resync/index.js","lineNumber":178,"sourceCode":"async function resyncGitea({ chunkSource }, response) {\n  if (!chunkSource) throw new Error(\"Invalid source property provided\");\n  try {\n    // Gitea file data is `payload` encrypted (might contain PAT). So we need to expand its\n    // encrypted payload back into query params so we can reFetch the page with same access token/params.\n    const source = response.locals.encryptionWorker.expandPayload(chunkSource);\n    const {\n      fetchGiteaFile,\n    } = require(\"../../utils/extensions/RepoLoader/GiteaRepo\");\n    const { success, reason, content } = await fetchGiteaFile({\n      // Gitea is self-hosted so the protocol was stored with the payload - it cannot be assumed.\n      repoUrl: `${source.searchParams.get(\"scheme\")}:${source.pathname}`,\n      branch: source.searchParams.get(\"branch\"),\n      accessToken: source.searchParams.get(\"pat\"),\n      sourceFilePath: source.searchParams.get(\"path\"),\n    });\n\n    if (!success)\n      throw new Error(`Failed to sync Gitea file content. ${reason}`);\n    response.status(200).json({ success, content });\n  } catch (e) {\n    console.error(e);\n    response.status(200).json({\n      success: false,\n      content: null,\n    });\n  }\n}\n\n/**\n * Fetches the content of a specific DrupalWiki page via its chunkSource.\n * Returns the content as a text string of the page in question and only that page.\n * @param {object} data - metadata from document (eg: chunkSource)\n * @param {import(\"../../middleware/setDataSigner\").ResponseWithSigner} response\n */\nasync function resyncDrupalWiki({ chunkSource }, response) {\n  if (!chunkSource) throw new Error(\"Invalid source property provided\");","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/extensions/resync/index.js#L160-L196","documentation":"Thrown by resyncGitea in collector/extensions/resync/index.js:178 when fetchGiteaFile(...) from collector/utils/extensions/RepoLoader/GiteaRepo resolves with success:false. Inputs come from decrypting chunkSource — note Gitea is self-hosted so the scheme itself is stored in the payload (scheme:pathname) plus branch, accessToken (pat), sourceFilePath. The interpolated `reason` carries the upstream cause. Handler catches and answers HTTP 200 with success:false, content:null.","triggerScenarios":"Gitea token expired/revoked or lacks read on the repo; file moved/deleted on branch; branch renamed; self-hosted Gitea instance moved host, changed scheme (http↔https), or cert changed; collector lacks network access.","commonSituations":"Self-hosted Gitea migrated to a new domain/port; token rotated; org/repo made private; cert self-signed and trust missing on the collector.","solutions":["Check `reason` for the upstream HTTP status.","Re-scrape the Gitea file with a valid access token to mint a fresh chunkSource (which re-records the current scheme and host).","Verify branch and file path still exist.","Confirm collector egress + TLS trust to the Gitea instance."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await resyncGitea({ chunkSource }, response); }\ncatch (e) {\n  if (e.message.startsWith(\"Failed to sync Gitea file content.\")) {\n    const upstream = e.message.replace(\"Failed to sync Gitea file content. \", \"\");\n    if (/401|403/i.test(upstream)) rotateGiteaToken();\n    else if (/404/i.test(upstream)) markFileMovedOrDeleted();\n    else if (/ECONNREFUSED|certificate|UNABLE_TO_VERIFY/i.test(upstream)) flagInstanceUnreachable();\n    else scheduleRetry();\n  }\n}","preventionTips":["Because Gitea is self-hosted, re-scrape after any host/port/scheme migration so chunkSource stays correct.","Trust the instance's TLS cert on the collector or rely on a scheme the instance actually serves.","Re-scrape whenever the access token rotates."],"tags":["auth","network","resync","gitea"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}