{"record":{"id":"3ab35bc535d65fa6","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-sync-link-content-reason","errorCode":null,"errorMessage":"Failed to sync link content. ${reason}","messagePattern":"Failed to sync link content\\. (.+?)","errorType":"exception","errorClass":"Error","httpStatus":200,"severity":"error","filePath":"collector/extensions/resync/index.js","lineNumber":12,"sourceCode":"const { getLinkText } = require(\"../../processLink\");\n\n/**\n * Fetches the content of a raw link. Returns the content as a text string of the link in question.\n * @param {object} data - metadata from document (eg: link)\n * @param {import(\"../../middleware/setDataSigner\").ResponseWithSigner} response\n */\nasync function resyncLink({ link }, response) {\n  if (!link) throw new Error(\"Invalid link provided\");\n  try {\n    const { success, content = null, reason } = await getLinkText(link);\n    if (!success) throw new Error(`Failed to sync link 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 YouTube link. Returns the content as a text string of the video in question.\n * We offer this as there may be some videos where a transcription could be manually edited after initial scraping\n * but in general - transcriptions often never change.\n * @param {object} data - metadata from document (eg: link)\n * @param {import(\"../../middleware/setDataSigner\").ResponseWithSigner} response\n */\nasync function resyncYouTube({ link }, response) {","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/collector/extensions/resync/index.js#L1-L30","documentation":"Thrown by resyncLink in collector/extensions/resync/index.js:12 when getLinkText(link) resolves with success:false. getLinkText itself returns success:false when its own validURL check fails (bad URL / private IP / non-http protocol) — see collector/processLink/index.js:36 — or when the downstream scrapeGenericUrl fails. The interpolated `reason` carries the upstream cause. The handler catches and answers HTTP 200 with success:false, content:null.","triggerScenarios":"Resyncing a link whose stored URL is now invalid, points at a private IP without COLLECTOR_ALLOW_ANY_IP, returns 4xx/5xx, times out, or has certificate/SSRF issues; or the target page no longer exists (404/410).","commonSituations":"External site went offline or was moved; corporate firewall blocks the collector egress; site now sits behind a private IP; SSL cert expired; rate-limited.","solutions":["Inspect the appended `reason` in the error — it is the upstream failure cause.","Verify the URL still loads from the collector host (curl from the container).","If the URL is a private/LAN resource, set COLLECTOR_ALLOW_ANY_IP=true.","Retry after transient network failures; for persistent 404, remove or re-add the document."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const { validURL, validateURL } = require(\"./utils/url\");\nfunction canResyncLink(link) {\n  const v = validateURL(link);\n  return { ok: validURL(v), url: v };\n}\n// reject early if the URL itself is the problem (most common upstream reason)\nconst pre = canResyncLink(link);\nif (!pre.ok) return skip(\"link not valid for resync\");","typeGuard":null,"tryCatchPattern":"// reason is interpolated — match prefix, not exact text\ntry { await resyncLink({ link }, response); }\ncatch (e) {\n  if (e.message.startsWith(\"Failed to sync link content.\")) {\n    const upstream = e.message.replace(\"Failed to sync link content. \", \"\");\n    if (/ENOTFOUND|ETIMEDOUT|ECONNRESET|5\\d\\d/.test(upstream)) scheduleRetry();\n    else markDocumentUnsyncable(upstream);\n  }\n}","preventionTips":["Treat `reason` as authoritative — log it before retrying.","Retry only transient/network reasons, not 404/410.","Confirm collector egress to the target host before scheduling a resync loop."],"tags":["network","resync","link","scraping"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}