Mintplex-Labs/anything-llm · warning · Error

Invalid link provided

Error message

Invalid link provided

What it means

Thrown by resyncLink in collector/extensions/resync/index.js:9 when the destructured `link` field from the document metadata is falsy. The resync-source-document dispatcher catches it and still returns HTTP 200 with success:false and content:null, so the error is surfaced to the caller as a failed re-sync, not an HTTP error.

Source

Thrown at collector/extensions/resync/index.js:9

const { getLinkText } = require("../../processLink");

/**
 * Fetches the content of a raw link. Returns the content as a text string of the link in question.
 * @param {object} data - metadata from document (eg: link)
 * @param {import("../../middleware/setDataSigner").ResponseWithSigner} response
 */
async function resyncLink({ link }, response) {
  if (!link) throw new Error("Invalid link provided");
  try {
    const { success, content = null, reason } = await getLinkText(link);
    if (!success) throw new Error(`Failed to sync link 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 YouTube link. Returns the content as a text string of the video in question.
 * We offer this as there may be some videos where a transcription could be manually edited after initial scraping
 * but in general - transcriptions often never change.
 * @param {object} data - metadata from document (eg: link)

View on GitHub (pinned to 526360e320)

Solutions

  1. Send options as { link: "<full http(s) URL>" }.
  2. Confirm the source document metadata actually has a non-empty `link` value before issuing resync.
  3. If the document is not link-based, pick the correct `type` (e.g. "youtube", "github").

Example fix

// before
RESYNC_METHODS.link({}, response);

// after
RESYNC_METHODS.link({ link: "https://example.com/article" }, response);
Defensive patterns

Strategy: validation

Validate before calling

function requireLink(options) {
  if (!options || typeof options.link !== "string" || options.link.trim().length === 0) {
    throw new Error("Invalid link provided");
  }
  return options.link;
}
const link = requireLink(options); // call before the API

Type guard

/** @param {{link?: unknown}} o */
function hasNonEmptyLink(o) {
  return o != null && typeof o.link === "string" && o.link.trim().length > 0;
}

Try / catch

// The dispatcher returns 200 + success:false — check the envelope
const result = await resyncLink({ link }, response);
if (result && result.success === false) handleMissingContent(result);

Prevention

When it happens

Trigger: POST /ext/resync-source-document with { type: "link", options: {} } or with options.link set to "", null, or undefined. Typically the document metadata row no longer has a stored link or the client passed the wrong shape.

Common situations: A previously scraped web-page document lost its `link` metadata; integration code passes the document object directly instead of { link }; a DB migration stripped the field.

Related errors


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