Mintplex-Labs/anything-llm · error · Error
Failed to sync GitHub file content. ${reason}
Error message
Failed to sync GitHub file content. ${reason} What it means
Thrown by resyncGithub in collector/extensions/resync/index.js:111 when fetchGithubFile(...) from collector/utils/extensions/RepoLoader/GithubRepo 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:111
*/
async function resyncGithub({ chunkSource }, response) {
if (!chunkSource) throw new Error("Invalid source property provided");
try {
// Github 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 {
fetchGithubFile,
} = require("../../utils/extensions/RepoLoader/GithubRepo");
const { success, reason, content } = await fetchGithubFile({
repoUrl: `https:${source.pathname}`, // need to add back the real protocol
branch: source.searchParams.get("branch"),
accessToken: source.searchParams.get("pat"),
sourceFilePath: source.searchParams.get("path"),
});
if (!success)
throw new Error(`Failed to sync GitHub 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 GitLab 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 resyncGitlab({ chunkSource }, response) {
if (!chunkSource) throw new Error("Invalid source property provided");View on GitHub (pinned to 526360e320)
Solutions
- Check `reason` for the GitHub HTTP status (401/403/404).
- Re-scrape the GitHub file with a valid PAT that has `repo` scope (or fine-grained read on the repo) to mint a fresh chunkSource.
- Verify the branch still exists and the file path is current.
- Confirm the collector's egress to api.github.com (or the GH enterprise host) is allowed.
Defensive patterns
Strategy: try-catch
Try / catch
try { await resyncGithub({ chunkSource }, response); }
catch (e) {
if (e.message.startsWith("Failed to sync GitHub file content.")) {
const upstream = e.message.replace("Failed to sync GitHub file content. ", "");
if (/401|403|bad credentials/i.test(upstream)) rotateGitHubPat();
else if (/404/i.test(upstream)) markFileMovedOrDeleted();
else if (/rate limit/i.test(upstream)) backoffAndRetry();
else scheduleRetry();
}
} Prevention
- Use a PAT with the minimum scope needed and rotate it before expiry.
- Re-scrape to mint a new chunkSource whenever the PAT changes — old payloads carry the old token.
- Watch for 404 — file moves are common in active repos.
When it happens
Trigger: PAT expired/revoked or lacks read on the repo; file moved or deleted on the branch; branch was renamed/deleted; private repo with no token; GitHub API rate limit (60/hr unauthenticated); repo transferred to another owner.
Common situations: Personal Access Token rotated since original scrape; file path changed in a refactor; repo transferred/renamed; classic PAT scoped to a different repo.
Related errors
- Failed to sync Confluence page content. ${reason}
- Failed to sync GitLab file content. ${reason}
- Failed to sync Gitea 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/3fdff0449b372038.
Report an issue: GitHub.