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

  1. Check `reason` for the upstream HTTP status.
  2. Re-scrape the Gitea file with a valid access token to mint a fresh chunkSource (which re-records the current scheme and host).
  3. Verify branch and file path still exist.
  4. 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

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


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