{"record":{"id":"e2c97122ff9d0bf0","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-sync-gitlab-file-content-reason","errorCode":null,"errorMessage":"Failed to sync GitLab file content. ${reason}","messagePattern":"Failed to sync GitLab file content\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":200,"severity":"error","filePath":"collector/extensions/resync/index.js","lineNumber":143,"sourceCode":" * @param {object} data - metadata from document (eg: chunkSource)\n * @param {import(\"../../middleware/setDataSigner\").ResponseWithSigner} response\n */\nasync function resyncGitlab({ chunkSource }, response) {\n  if (!chunkSource) throw new Error(\"Invalid source property provided\");\n  try {\n    const source = response.locals.encryptionWorker.expandPayload(chunkSource);\n    const {\n      fetchGitlabFile,\n    } = require(\"../../utils/extensions/RepoLoader/GitlabRepo\");\n    const { success, reason, content } = await fetchGitlabFile({\n      repoUrl: `https:${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 GitLab 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 Gitea file via its chunkSource.\n * Returns the content as a text string of the file in question and only that file.\n * @param {object} data - metadata from document (eg: chunkSource)\n * @param {import(\"../../middleware/setDataSigner\").ResponseWithSigner} response\n */\nasync function resyncGitea({ chunkSource }, response) {\n  if (!chunkSource) throw new Error(\"Invalid source property provided\");","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/extensions/resync/index.js#L125-L161","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check `reason` for the GitLab HTTP status (401/403/404).","Re-scrape the GitLab file with a valid PAT (api or read_repository scope) to mint a new chunkSource.","Verify branch and file path still exist.","Confirm collector egress to the GitLab host (and TLS validity) works."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await resyncGitlab({ chunkSource }, response); }\ncatch (e) {\n  if (e.message.startsWith(\"Failed to sync GitLab file content.\")) {\n    const upstream = e.message.replace(\"Failed to sync GitLab file content. \", \"\");\n    if (/401|403/i.test(upstream)) rotateGitlabPat();\n    else if (/404/i.test(upstream)) markFileMovedOrDeleted();\n    else scheduleRetry();\n  }\n}","preventionTips":["Use a token with api or read_repository scope and rotate before expiry.","Re-scrape to refresh chunkSource whenever the token changes.","Verify collector egress + TLS to the GitLab host."],"tags":["auth","network","resync","gitlab"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}