Mintplex-Labs/anything-llm · error · Error
Failed to sync Gitea file content. ${reason}
Error message
Failed to sync Gitea file content. ${reason} What it means
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.
Source
Thrown at collector/extensions/resync/index.js:178
async function resyncGitea({ chunkSource }, response) {
if (!chunkSource) throw new Error("Invalid source property provided");
try {
// Gitea file data is `payload` encrypted (might contain PAT). So we need to expand its
// encrypted payload back into query params so we can reFetch the page with same access token/params.
const source = response.locals.encryptionWorker.expandPayload(chunkSource);
const {
fetchGiteaFile,
} = require("../../utils/extensions/RepoLoader/GiteaRepo");
const { success, reason, content } = await fetchGiteaFile({
// Gitea is self-hosted so the protocol was stored with the payload - it cannot be assumed.
repoUrl: `${source.searchParams.get("scheme")}:${source.pathname}`,
branch: source.searchParams.get("branch"),
accessToken: source.searchParams.get("pat"),
sourceFilePath: source.searchParams.get("path"),
});
if (!success)
throw new Error(`Failed to sync Gitea file content. ${reason}`);
response.status(200).json({ success, content });
} catch (e) {
console.error(e);
response.status(200).json({
success: false,
content: null,
});
}
}
/**
* Fetches the content of a specific DrupalWiki page via its chunkSource.
* Returns the content as a text string of the page in question and only that page.
* @param {object} data - metadata from document (eg: chunkSource)
* @param {import("../../middleware/setDataSigner").ResponseWithSigner} response
*/
async function resyncDrupalWiki({ chunkSource }, response) {
if (!chunkSource) throw new Error("Invalid source property provided");View on GitHub (pinned to 526360e320)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try { await resyncGitea({ chunkSource }, response); }
catch (e) {
if (e.message.startsWith("Failed to sync Gitea file content.")) {
const upstream = e.message.replace("Failed to sync Gitea file content. ", "");
if (/401|403/i.test(upstream)) rotateGiteaToken();
else if (/404/i.test(upstream)) markFileMovedOrDeleted();
else if (/ECONNREFUSED|certificate|UNABLE_TO_VERIFY/i.test(upstream)) flagInstanceUnreachable();
else scheduleRetry();
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Self-hosted Gitea migrated to a new domain/port; token rotated; org/repo made private; cert self-signed and trust missing on the collector.
Related errors
- Failed to sync Confluence page content. ${reason}
- Failed to sync GitHub file content. ${reason}
- Failed to sync GitLab file content. ${reason}
- Failed to fetch document content
- Failed to sync link content. ${reason}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/17744afa51a8d78f.
Report an issue: GitHub.