Mintplex-Labs/anything-llm · error · Error

Failed to sync GitLab file content. ${reason}

Error message

Failed to sync GitLab file content. ${reason}

What it means

Thrown by resyncGitlab in collector/extensions/resync/index.js:143 when fetchGitlabFile(...) from collector/utils/extensions/RepoLoader/GitlabRepo resolves with success:false. Inputs come from decrypting chunkSource — repoUrl, 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:143

 * @param {object} data - metadata from document (eg: chunkSource)
 * @param {import("../../middleware/setDataSigner").ResponseWithSigner} response
 */
async function resyncGitlab({ chunkSource }, response) {
  if (!chunkSource) throw new Error("Invalid source property provided");
  try {
    const source = response.locals.encryptionWorker.expandPayload(chunkSource);
    const {
      fetchGitlabFile,
    } = require("../../utils/extensions/RepoLoader/GitlabRepo");
    const { success, reason, content } = await fetchGitlabFile({
      repoUrl: `https:${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 GitLab 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 Gitea file via its chunkSource.
 * Returns the content as a text string of the file in question and only that file.
 * @param {object} data - metadata from document (eg: chunkSource)
 * @param {import("../../middleware/setDataSigner").ResponseWithSigner} response
 */
async function resyncGitea({ chunkSource }, response) {
  if (!chunkSource) throw new Error("Invalid source property provided");

View on GitHub (pinned to 526360e320)

Solutions

  1. Check `reason` for the GitLab HTTP status (401/403/404).
  2. Re-scrape the GitLab file with a valid PAT (api or read_repository scope) to mint a new chunkSource.
  3. Verify branch and file path still exist.
  4. Confirm collector egress to the GitLab host (and TLS validity) works.
Defensive patterns

Strategy: try-catch

Try / catch

try { await resyncGitlab({ chunkSource }, response); }
catch (e) {
  if (e.message.startsWith("Failed to sync GitLab file content.")) {
    const upstream = e.message.replace("Failed to sync GitLab file content. ", "");
    if (/401|403/i.test(upstream)) rotateGitlabPat();
    else if (/404/i.test(upstream)) markFileMovedOrDeleted();
    else scheduleRetry();
  }
}

Prevention

When it happens

Trigger: GitLab PAT expired/revoked or lacks read_scope; project visibility changed to private without token; file moved/deleted on the branch; branch renamed; self-hosted GitLab moved host or cert changed; rate limited.

Common situations: Project access token rotated; project transferred to another group; self-hosted GitLab cert renewed and now mismatches; collector has no egress to the GitLab host.

Related errors


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